Tài liệu về nhà → Hướng dẫn sử dụng MongoDB → MongoDB Manual
MongoDB cung cấp một giải pháp tìm kiếm toàn văn bản, tìm kiếm Atlas MongoDB, cho dữ liệu được lưu trữ trên Atlas MongoDB. Người dùng chạy triển khai MongoDB tự quản lý có quyền truy cập vào khả năng tìm kiếm văn bản tại chỗ.full-text search solution, MongoDB Atlas Search, for data hosted on MongoDB Atlas. Users running self-managed MongoDB deployments have access to on-premises text search capabilities.
Đối với người dùng MongoDB Atlas, tìm kiếm Atlas của MongoDB hỗ trợ lập chỉ mục văn bản chi tiết và ngôn ngữ truy vấn phong phú cho kết quả tìm kiếm nhanh, có liên quan. Để tìm hiểu thêm về các chỉ mục tìm kiếm toàn văn bản và truy vấn
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Atlas Các giai đoạn đường ống tổng hợp tìm kiếm
Xác định các chỉ mục tìm kiếm Atlas
Chạy các truy vấn tìm kiếm Atlas
Atlas Search cũng cung cấp các máy phân tích chung cho văn bản phân tích cú pháp cho tìm kiếm toàn văn, bao gồm hỗ trợ cho hơn 40 máy phân tích cụ thể ngôn ngữ. also offers common analyzers for parsing text for full-text search, including support for over 40 language-specific analyzers.
Đối với triển khai tại chỗ (không phải ATLAS), khả năng tìm kiếm văn bản của MongoDB hỗ trợ các hoạt động truy vấn thực hiện tìm kiếm văn bản của nội dung chuỗi. Để thực hiện tìm kiếm văn bản, MongoDB sử dụng chỉ mục văn bản và toán tử
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Ghi chú
Lượt xem không hỗ trợ tìm kiếm văn bản.
Để tìm hiểu thêm về tìm kiếm văn bản để triển khai tại chỗ, xem:
Chỉ mục văn bản
Toán tử tìm kiếm văn bản
MongoDB cũng hỗ trợ tìm kiếm văn bản cho các ngôn ngữ khác nhau. Xem ngôn ngữ tìm kiếm văn bản để biết danh sách các ngôn ngữ được hỗ trợ.
Xem thêm: → MongoDB Manual
Bắt đầu từ MongoDB 4.4, bạn có thể chỉ định biểu thức
"\"ssl certificate\" authority key"
49 trong"\"ssl certificate\" authority key"
48 mà không chỉ định biểu thức trong phép chiếu. Ví dụ,full-text search solution, MongoDB Atlas Search, for data hosted on MongoDB Atlas. Users running self-managed MongoDB deployments have access to on-premises text search capabilities.Do đó, bạn có thể sắp xếp các tài liệu kết quả theo mức độ liên quan tìm kiếm của họ mà không cần chiếu
db.articles.createIndex( { subject: "text" } )
06.db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
4 performs a text search on the content of the fields indexed with a
text index. A db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
4 expression has the following syntax:db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
{ |
$text: |
{ |
$search: <string>, |
$language: <string>, |
$caseSensitive: <boolean>, |
$diacriticSensitive: <boolean> |
} |
} |
Toán tử
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
| sợi dây | Một chuỗi các thuật ngữ mà mongDB phân tích và sử dụng để truy vấn chỉ mục văn bản. MongoDB thực hiện tìm kiếm logic db.articles.find( { $text: { $search: "coffee" } } ) | ||||||||||
db.articles.find( { $text: { $search: "coffee" } } ) | sợi dây | Một chuỗi các thuật ngữ mà mongDB phân tích và sử dụng để truy vấn chỉ mục văn bản. MongoDB thực hiện tìm kiếm logic db.articles.find( { $text: { $search: "coffee" } } ) 1 về các thuật ngữ trừ khi được chỉ định là cụm từ. Xem hành vi để biết thêm thông tin trên lĩnh vực này.Không bắt buộc. Ngôn ngữ xác định danh sách các từ dừng cho tìm kiếm và các quy tắc cho stemmer và tokenizer. Nếu không được chỉ định, tìm kiếm sử dụng ngôn ngữ mặc định của chỉ mục. Đối với các ngôn ngữ được hỗ trợ, xem ngôn ngữ tìm kiếm văn bản. | ||||||||||
db.articles.find( { $text: { $search: "coffee" } } ) | boolean | Nếu bạn chỉ định giá trị ngôn ngữ là db.articles.find( { $text: { $search: "coffee" } } ) 3, thì tìm kiếm văn bản sử dụng mã thông báo đơn giản mà không có danh sách các từ dừng và không có nguồn gốc.Không bắt buộc. Một lá cờ Boolean để kích hoạt hoặc vô hiệu hóa tìm kiếm nhạy cảm trường hợp. Mặc định là db.articles.find( { $text: { $search: "coffee" } } ) 5; tức là tìm kiếm bảo vệ sự vô cảm của trường hợp của chỉ mục văn bản.Case Insensitivity. | ||||||||||
db.articles.find( { $text: { $search: "coffee" } } ) | boolean | Để biết thêm thông tin, xem trường hợp vô cảm. Không bắt buộc. Một lá cờ Boolean để bật hoặc vô hiệu hóa tìm kiếm nhạy cảm với DiaCritic so với các chỉ mục văn bản phiên bản 3. Mặc định là db.articles.find( { $text: { $search: "coffee" } } ) 5; tức là các tìm kiếm bảo vệ sự không nhạy cảm của dấu hiệu của chỉ sốdb.articles.find( { $text: { $search: "coffee" } } ) 8.Các tìm kiếm văn bản đối với các phiên bản trước của chỉ số db.articles.find( { $text: { $search: "coffee" } } ) 8 vốn đã nhạy cảm với dấu phụ và không thể điều chỉnh không nhạy cảm. Như vậy, tùy chọndb.articles.find( { $text: { $search: "coffee" } } ) 6 không có tác dụng với các phiên bản trước của chỉ mụcdb.articles.find( { $text: { $search: "coffee" } } ) 8.Diacritic Insensitivity. |
Để biết thêm thông tin, hãy xem sự vô cảm của Diacritic.
4 operator, by default, does not return results sorted in terms of the results' scores. For more information on sorting by the text search scores, see the Text Score
documentation.db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
Toán tử
4, theo mặc định, không trả về kết quả được sắp xếp theo điểm số của kết quả. Để biết thêm thông tin về việc sắp xếp theo điểm tìm kiếm văn bản, hãy xem tài liệu điểm văn bản.db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
4 expression.db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] ) Một truy vấn có thể chỉ định, nhiều nhất là một biểu thức
4.db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
4 query can not appear indb.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
5 expressions.{ _id: 1, subject: 'coffee', author: 'xyz', views: 50 }, { _id: 7, subject: 'coffee and cream', author: 'efg', views: 10 }, { _id: 2, subject: 'Coffee Shopping', author: 'efg', views: 5 } Truy vấn
4 không thể xuất hiện trong các biểu thứcdb.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
5.{ _id: 1, subject: 'coffee', author: 'xyz', views: 50 }, { _id: 7, subject: 'coffee and cream', author: 'efg', views: 10 }, { _id: 2, subject: 'Coffee Shopping', author: 'efg', views: 5 }
4 query can not appear indb.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
7 query expressions or{ _id: 1, subject: 'coffee', author: 'xyz', views: 50 }, { _id: 7, subject: 'coffee and cream', author: 'efg', views: 10 }, { _id: 2, subject: 'Coffee Shopping', author: 'efg', views: 5 }
7 projection expressions.{ _id: 1, subject: 'coffee', author: 'xyz', views: 50 }, { _id: 7, subject: 'coffee and cream', author: 'efg', views: 10 }, { _id: 2, subject: 'Coffee Shopping', author: 'efg', views: 5 } Truy vấn
4 không thể xuất hiện trong các biểu thức truy vấndb.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
7 hoặc các biểu thức trình chiếu{ _id: 1, subject: 'coffee', author: 'xyz', views: 50 }, { _id: 7, subject: 'coffee and cream', author: 'efg', views: 10 }, { _id: 2, subject: 'Coffee Shopping', author: 'efg', views: 5 }
7.{ _id: 1, subject: 'coffee', author: 'xyz', views: 50 }, { _id: 7, subject: 'coffee and cream', author: 'efg', views: 10 }, { _id: 2, subject: 'Coffee Shopping', author: 'efg', views: 5 }
4 query in andb.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] ) db.articles.find( { $text: { $search: "bake coffee cake" } } )
0 expression, all clauses in thedb.articles.find( { $text: { $search: "bake coffee cake" } } )
0 array must be indexed.Để sử dụng truy vấn
4 trong biểu thứcdb.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] ) db.articles.find( { $text: { $search: "bake coffee cake" } } )
0, tất cả các mệnh đề trong mảngdb.articles.find( { $text: { $search: "bake coffee cake" } } )
0 phải được lập chỉ mục.
4 query expression.db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] ) Bạn không thể sử dụng
db.articles.find( { $text: { $search: "bake coffee cake" } } )
2 nếu truy vấn bao gồm biểu thức truy vấn
4.db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
4 expression.db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] ) Bạn không thể chỉ định thứ tự sắp xếp
db.articles.find( { $text: { $search: "bake coffee cake" } } )
4 nếu truy vấn bao gồm biểu thức
4.db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
4 expression, which requires a special text index, with a query operator that requires a different type of special index. For example you cannot combinedb.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
4 expression with thedb.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] ) db.articles.find( { $text: { $search: "bake coffee cake" } } )
8 operator.Bạn không thể kết hợp biểu thức
4, yêu cầu chỉ mục văn bản đặc biệt, với toán tử truy vấn yêu cầu một loại chỉ mục đặc biệt khác. Ví dụ: bạn không thể kết hợp biểu thứcdb.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
4 với toán tửdb.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] ) db.articles.find( { $text: { $search: "bake coffee cake" } } )
8.
Lượt xem không hỗ trợ tìm kiếm văn bản.
4 operator in aggregation, the following restrictions also apply.db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
Nếu sử dụng toán tử
4 trong tập hợp, các hạn chế sau cũng được áp dụng.db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
4 must be the first stage in the pipeline.db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] ) Giai đoạn
0 bao gồm{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 } { "_id" : 7, "subject" : "coffee and cream", "author" : "efg", "views" : 10 } { "_id" : 1, "subject" : "coffee", "author" : "xyz", "views" : 50 } { "_id" : 3, "subject" : "Baking a cake", "author" : "abc", "views" : 90 } { "_id" : 4, "subject" : "baking", "author" : "xyz", "views" : 100 }
4 phải là giai đoạn đầu tiên trong đường ống.db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
4 operator can only occur once in the stage.db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] ) Một toán tử
4 chỉ có thể xảy ra một lần trong giai đoạn.db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
4 operator expression cannot appear indb.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] ) db.articles.find( { $text: { $search: "bake coffee cake" } } )
0 or
5 expressions.{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 } { "_id" : 7, "subject" : "coffee and cream", "author" : "efg", "views" : 10 } { "_id" : 1, "subject" : "coffee", "author" : "xyz", "views" : 50 } { "_id" : 3, "subject" : "Baking a cake", "author" : "abc", "views" : 90 } { "_id" : 4, "subject" : "baking", "author" : "xyz", "views" : 100 } Biểu thức toán tử
4 không thể xuất hiện trong các biểu thứcdb.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] ) db.articles.find( { $text: { $search: "bake coffee cake" } } )
0 hoặc
5.{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 } { "_id" : 7, "subject" : "coffee and cream", "author" : "efg", "views" : 10 } { "_id" : 1, "subject" : "coffee", "author" : "xyz", "views" : 50 } { "_id" : 3, "subject" : "Baking a cake", "author" : "abc", "views" : 90 } { "_id" : 4, "subject" : "baking", "author" : "xyz", "views" : 100 }
Tìm kiếm văn bản, theo mặc định, không trả về các tài liệu phù hợp theo thứ tự điểm phù hợp. Để sắp xếp theo điểm giảm dần, hãy sử dụng biểu thức tổng hợp
{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 } |
{ "_id" : 7, "subject" : "coffee and cream", "author" : "efg", "views" : 10 } |
{ "_id" : 1, "subject" : "coffee", "author" : "xyz", "views" : 50 } |
{ "_id" : 3, "subject" : "Baking a cake", "author" : "abc", "views" : 90 } |
{ "_id" : 4, "subject" : "baking", "author" : "xyz", "views" : 100 } |
{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 } |
{ "_id" : 7, "subject" : "coffee and cream", "author" : "efg", "views" : 10 } |
{ "_id" : 1, "subject" : "coffee", "author" : "xyz", "views" : 50 } |
{ "_id" : 3, "subject" : "Baking a cake", "author" : "abc", "views" : 90 } |
{ "_id" : 4, "subject" : "baking", "author" : "xyz", "views" : 100 } |
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Trong trường
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.find( { $text: { $search: "\"coffee shop\"" } } )
1) that negates term or an escaped double quotesdb.articles.find( { $text: { $search: "\"coffee shop\"" } } )
2 that specifies a phrase.Toán tử
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.find( { $text: { $search: "\"coffee shop\"" } } )
1) phủ nhận thuật ngữ hoặc một trích dẫn kép thoát radb.articles.find( { $text: { $search: "\"coffee shop\"" } } )
2 chỉ định một cụm từ.Ghi chú
4 expression is different than the the
$search aggregation stage provided by Atlas Search. The db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Trường
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Để phù hợp với một cụm từ, trái ngược với các thuật ngữ cá nhân, gửi lại cụm từ trong trích dẫn kép thoát (
db.articles.find( { $text: { $search: "\"coffee shop\"" } } )
2), như trong:Nếu chuỗi
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
"\"ssl certificate\" authority key"
Ví dụ: đã vượt qua chuỗi
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
0.Toán tử
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
0.Tiền tố một từ có dấu gạch nối (
db.articles.find( { $text: { $search: "\"coffee shop\"" } } )
1) phủ nhận một từ:Từ phủ định loại trừ các tài liệu chứa từ phủ định từ tập kết quả.
Khi được truyền một chuỗi tìm kiếm chỉ chứa các từ phủ định, tìm kiếm văn bản sẽ không khớp với bất kỳ tài liệu nào.
4 operator treats the hyphen-minus (db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] ) db.articles.find( { $text: { $search: "\"coffee shop\"" } } )
1) as a delimiter. To negate the word{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
5 in this instance, include a space between{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
6 and{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
7, i.e.,{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
8.
Toán tử
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
"\"ssl certificate\" authority key"
00.db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
"\"ssl certificate\" authority key"
00 operator.Nhà điều hành
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
"\"ssl certificate\" authority key"
02 và"\"ssl certificate\" authority key"
03 trong tiếng Anh.db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
"\"ssl certificate\" authority key"
02 and"\"ssl certificate\" authority key"
03 in English.Đối với trường hợp không nhạy cảm và điều chỉnh các tìm kiếm văn bản không nhạy cảm, toán tử
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
"\"ssl certificate\" authority key"
05, một tìm kiếm trên thuật ngữ"\"ssl certificate\" authority key"
06 sẽ không khớp. Tuy nhiên,"\"ssl certificate\" authority key"
05 hoặc"\"ssl certificate\" authority key"
08 sẽ phù hợp.db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
"\"ssl certificate\" authority key"
05, a search on the term"\"ssl certificate\" authority key"
06 will not match. However,"\"ssl certificate\" authority key"
05 or"\"ssl certificate\" authority key"
08 will match.Đối với tìm kiếm nhạy cảm trường hợp (nghĩa là
"\"ssl certificate\" authority key"
09), nếu gốc hậu tố chứa các chữ cái viết hoa, toán tửdb.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
"\"ssl certificate\" authority key"
09), if the suffix stem contains uppercase letters, thedb.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Đối với tìm kiếm nhạy cảm với diacritic (nghĩa là
"\"ssl certificate\" authority key"
11), nếu thân hậu tố chứa dấu hoặc dấu hiệu diarritic, toán tửdb.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
"\"ssl certificate\" authority key"
11), if the suffix stem contains the diacritic mark or marks, thedb.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Toán tử
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Chỉ số văn bản phiên bản 3 không nhạy cảm với các ký tự Latin có hoặc không có dấu hiệu và ký tự từ bảng chữ cái không phải là Latin, chẳng hạn như bảng chữ cái Cyrillic. Xem chỉ mục văn bản để biết chi tiết.
Các phiên bản trước của chỉ số
db.articles.find( { $text: { $search: "coffee" } } )
8 là trường hợp không nhạy cảm với các ký tự Latin mà không có dấu hiệu phụ; tức là cho"\"ssl certificate\" authority key"
15.
Để hỗ trợ tìm kiếm nhạy cảm trường hợp trong đó chỉ số
db.articles.find( { $text: { $search: "coffee" } } )
8 không nhạy cảm với trường hợp, chỉ định"\"ssl certificate\" authority key"
09.Khi thực hiện tìm kiếm nhạy cảm trường hợp (
"\"ssl certificate\" authority key"
09) trong đó chỉ sốdb.articles.find( { $text: { $search: "coffee" } } )
8 không nhạy cảm, toán tửdb.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Đầu tiên tìm kiếm chỉ số
db.articles.find( { $text: { $search: "coffee" } } )
8 cho các trường hợp không nhạy cảm và phù hợp.Sau đó, để trả về chỉ các tài liệu phù hợp với trường hợp của các thuật ngữ tìm kiếm, thao tác truy vấn
4 bao gồm một giai đoạn bổ sung để lọc các tài liệu không khớp với trường hợp được chỉ định.db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
4 query operation includes an additional stage to filter out the documents that do not match the specified case.db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
Đối với tìm kiếm nhạy cảm trường hợp (nghĩa là
"\"ssl certificate\" authority key"
09), nếu gốc hậu tố chứa các chữ cái viết hoa, toán tửdb.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Đối với tìm kiếm nhạy cảm với diacritic (nghĩa là
"\"ssl certificate\" authority key"
11), nếu thân hậu tố chứa dấu hoặc dấu hiệu diarritic, toán tửdb.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Toán tử
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Chỉ số văn bản phiên bản 3 không nhạy cảm với các ký tự Latin có hoặc không có dấu hiệu và ký tự từ bảng chữ cái không phải là Latin, chẳng hạn như bảng chữ cái Cyrillic. Xem chỉ mục văn bản để biết chi tiết.
Các phiên bản trước của chỉ số
db.articles.find( { $text: { $search: "coffee" } } )
8 là trường hợp không nhạy cảm với các ký tự Latin mà không có dấu hiệu phụ; tức là cho"\"ssl certificate\" authority key"
15.db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Để hỗ trợ tìm kiếm nhạy cảm trường hợp trong đó chỉ số
db.articles.find( { $text: { $search: "coffee" } } )
8 không nhạy cảm với trường hợp, chỉ định"\"ssl certificate\" authority key"
09.Khi thực hiện tìm kiếm nhạy cảm trường hợp (
"\"ssl certificate\" authority key"
09) trong đó chỉ sốdb.articles.find( { $text: { $search: "coffee" } } )
8 không nhạy cảm, toán tử
4:db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
Đầu tiên tìm kiếm chỉ số
db.articles.find( { $text: { $search: "coffee" } } )
8 cho các trường hợp không nhạy cảm và phù hợp.Sau đó, để trả về chỉ các tài liệu phù hợp với trường hợp của các thuật ngữ tìm kiếm, thao tác truy vấn
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.find( { $text: { $search: "coffee" } } )
8 index.Chỉ định
"\"ssl certificate\" authority key"
09 có thể ảnh hưởng đến hiệu suất.db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Mẹo
Xem thêm:
4 query operation includes an additional stage to filter out the documents that do not match.db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
Toán tử
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Chỉ số văn bản phiên bản 3 là không nhạy cảm. Đó là, chỉ số không phân biệt giữa các ký tự có chứa các dấu hiệu điều hòa và đối tác không được đánh dấu của chúng, chẳng hạn như
"\"ssl certificate\" authority key"
27,"\"ssl certificate\" authority key"
28 và"\"ssl certificate\" authority key"
29.db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.find( { $text: { $search: "coffee" } } )
8 index, which is diacritic sensitive.Các phiên bản trước đó của chỉ số
db.articles.find( { $text: { $search: "coffee" } } )
8 rất nhạy cảm.db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Toán tử
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Chỉ số văn bản phiên bản 3 không nhạy cảm với các ký tự Latin có hoặc không có dấu hiệu và ký tự từ bảng chữ cái không phải là Latin, chẳng hạn như bảng chữ cái Cyrillic. Xem chỉ mục văn bản để biết chi tiết.
Các phiên bản trước của chỉ số
db.articles.find( { $text: { $search: "coffee" } } )
8 là trường hợp không nhạy cảm với các ký tự Latin mà không có dấu hiệu phụ; tức là cho"\"ssl certificate\" authority key"
15.db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
"\"ssl certificate\" authority key"
48 method specification as well as part of the projection expression. The"\"ssl certificate\" authority key"
49 expression provides information on the processing of thedb.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 } |
{ "_id" : 7, "subject" : "coffee and cream", "author" : "efg", "views" : 10 } |
{ "_id" : 1, "subject" : "coffee", "author" : "xyz", "views" : 50 } |
{ "_id" : 3, "subject" : "Baking a cake", "author" : "abc", "views" : 90 } |
{ "_id" : 4, "subject" : "baking", "author" : "xyz", "views" : 100 } |
Để hỗ trợ tìm kiếm nhạy cảm trường hợp trong đó chỉ số
db.articles.find( { $text: { $search: "coffee" } } )
8 không nhạy cảm với trường hợp, chỉ định"\"ssl certificate\" authority key"
09.db.articles.createIndex( { subject: "text" } )
Khi thực hiện tìm kiếm nhạy cảm trường hợp (
"\"ssl certificate\" authority key"
09) trong đó chỉ sốdb.articles.find( { $text: { $search: "coffee" } } )
8 không nhạy cảm, toán tửdb.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Đầu tiên tìm kiếm chỉ số
db.articles.find( { $text: { $search: "coffee" } } )
8 cho các trường hợp không nhạy cảm và phù hợp.db.articles.find( { $text: { $search: "coffee" } } )
Sau đó, để trả về chỉ các tài liệu phù hợp với trường hợp của các thuật ngữ tìm kiếm, thao tác truy vấn
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
{ _id: 1, subject: 'coffee', author: 'xyz', views: 50 }, |
{ _id: 7, subject: 'coffee and cream', author: 'efg', views: 10 }, |
{ _id: 2, subject: 'Coffee Shopping', author: 'efg', views: 5 } |
Toán tử
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Chỉ số văn bản phiên bản 3 không nhạy cảm với các ký tự Latin có hoặc không có dấu hiệu và ký tự từ bảng chữ cái không phải là Latin, chẳng hạn như bảng chữ cái Cyrillic. Xem chỉ mục văn bản để biết chi tiết.
4 operator performs a logical db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
db.articles.find( { $text: { $search: "coffee" } } )
1 search on each term and returns documents that contains any of the terms.Các phiên bản trước của chỉ số
db.articles.find( { $text: { $search: "coffee" } } )
8 là trường hợp không nhạy cảm với các ký tự Latin mà không có dấu hiệu phụ; tức là cho"\"ssl certificate\" authority key"
15.db.articles.find( { $text: { $search: "bake coffee cake" } } )
Truy vấn này trả về các tài liệu có chứa
"\"ssl certificate\" authority key"
62 hoặc"\"ssl certificate\" authority key"
55 hoặc"\"ssl certificate\" authority key"
64 trong trường"\"ssl certificate\" authority key"
53 được lập chỉ mục, hay chính xác hơn là phiên bản gốc của các từ này:or"\"ssl certificate\" authority key"
55 or"\"ssl certificate\" authority key"
64 in the indexed"\"ssl certificate\" authority key"
53 field, or more precisely, the stemmed version of these words:{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 } |
{ "_id" : 7, "subject" : "coffee and cream", "author" : "efg", "views" : 10 } |
{ "_id" : 1, "subject" : "coffee", "author" : "xyz", "views" : 50 } |
{ "_id" : 3, "subject" : "Baking a cake", "author" : "abc", "views" : 90 } |
{ "_id" : 4, "subject" : "baking", "author" : "xyz", "views" : 100 } |
Mẹo
Để phù hợp với cụm từ chính xác như một thuật ngữ duy nhất, hãy thoát các trích dẫn.
Các truy vấn sau đây tìm kiếm cụm từ
"\"ssl certificate\" authority key"
66:db.articles.find( { $text: { $search: "\"coffee shop\"" } } )
Truy vấn này trả về các tài liệu chứa cụm từ
"\"ssl certificate\" authority key"
66:{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
Mẹo
Để phù hợp với cụm từ chính xác như một thuật ngữ duy nhất, hãy thoát các trích dẫn.
Các truy vấn sau đây tìm kiếm cụm từ
"\"ssl certificate\" authority key"
66:db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Truy vấn này trả về các tài liệu chứa cụm từ
"\"ssl certificate\" authority key"
66:not contain the term"\"ssl certificate\" authority key"
71, or more precisely the stemmed version of the words:"\"ssl certificate\" authority key"
0{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
"\"ssl certificate\" authority key"
1Mẹo
Để phù hợp với cụm từ chính xác như một thuật ngữ duy nhất, hãy thoát các trích dẫn.
4 expression to specify a language that
determines the list of stop words and the rules for the stemmer and tokenizer for the search string.db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
Các truy vấn sau đây tìm kiếm cụm từ
"\"ssl certificate\" authority key"
66:Truy vấn này trả về các tài liệu chứa cụm từ
"\"ssl certificate\" authority key"
66:"\"ssl certificate\" authority key"
2{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
"\"ssl certificate\" authority key"
3Xem thêm:
4 expression can also accept the language by name, db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] )
"\"ssl certificate\" authority key"
77. See Text Search Languages for the supported languages.Mẹo
Để phù hợp với cụm từ chính xác như một thuật ngữ duy nhất, hãy thoát các trích dẫn.
Các truy vấn sau đây tìm kiếm cụm từ
"\"ssl certificate\" authority key"
66:db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.find( { $text: { $search: "coffee" } } )
8 index. The version 3db.articles.find( { $text: { $search: "coffee" } } )
8 index is diacritic insensitive and expands its case insensitivity to include the Cyrillic alphabet as well as characters with diacritics. For details, see text Index Case Insensitivity and text Index Diacritic Insensitivity.Truy vấn này trả về các tài liệu chứa cụm từ
"\"ssl certificate\" authority key"
66:"\"ssl certificate\" authority key"
4{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
"\"ssl certificate\" authority key"
5Xem thêm:
Mẹo
Một thuật ngữ phủ định là một thuật ngữ được đặt trước một dấu hiệu trừ
db.articles.find( { $text: { $search: "\"coffee shop\"" } } )
1. Nếu bạn phủ nhận một thuật ngữ, toán tửdb.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Ví dụ sau đây tìm kiếm các tài liệu chứa các từ
"\"ssl certificate\" authority key"
55 nhưng không chứa thuật ngữ"\"ssl certificate\" authority key"
71 hoặc chính xác hơn là phiên bản gốc của các từ:"\"ssl certificate\" authority key"
6Truy vấn trả về các tài liệu sau:
"\"ssl certificate\" authority key"
7Mẹo
Sử dụng trường
db.articles.find( { $text: { $search: "coffee" } } )
2 tùy chọn trong biểu thứcdb.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
"\"ssl certificate\" authority key"
8Truy vấn trả về các tài liệu sau:
"\"ssl certificate\" authority key"
9Mẹo
Sử dụng trường
db.articles.find( { $text: { $search: "coffee" } } )
2 tùy chọn trong biểu thứcdb.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Nếu bạn chỉ định giá trị ngôn ngữ là
db.articles.find( { $text: { $search: "coffee" } } )
3, thì tìm kiếm văn bản sử dụng mã thông báo đơn giản mà không có danh sách các từ dừng và không có nguồn gốc.not contain the lower-case term"\"ssl certificate\" authority key"
71, or more precisely the stemmed version of the words:db.articles.createIndex( { subject: "text" } )
0Truy vấn sau đây chỉ định
"\"ssl certificate\" authority key"
75, tức là tiếng Tây Ban Nha, là ngôn ngữ xác định mã thông báo, xuất phát và dừng các từ:db.articles.createIndex( { subject: "text" } )
1Mẹo
Biểu thức
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
"\"ssl certificate\" authority key"
77. Xem ngôn ngữ tìm kiếm văn bản cho các ngôn ngữ được hỗ trợ.Toán tử
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.find( { $text: { $search: "coffee" } } )
8. Chỉ số phiên bản 3db.articles.find( { $text: { $search: "coffee" } } )
8 là không nhạy cảm và mở rộng trường hợp không nhạy cảm của nó để bao gồm bảng chữ cái cyrillic cũng như các ký tự có dấu hiệu. Để biết chi tiết, xem Index Index Incent tính không nhạy cảm và chỉ số văn bản không nhạy cảm.db.articles.createIndex( { subject: "text" } )
2Truy vấn sau đây thực hiện một trường hợp và tìm kiếm văn bản không nhạy cảm với các thuật ngữ
"\"ssl certificate\" authority key"
81 hoặc"\"ssl certificate\" authority key"
82:db.articles.createIndex( { subject: "text" } )
3Mẹo
Sử dụng chỉ mục phiên bản 3
db.articles.find( { $text: { $search: "coffee" } } )
8, truy vấn phù hợp với các tài liệu sau.db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Với các phiên bản trước của chỉ mục
db.articles.find( { $text: { $search: "coffee" } } )
8, truy vấn sẽ không khớp với bất kỳ tài liệu nào.db.articles.createIndex( { subject: "text" } )
4Truy vấn sau đây chỉ định
"\"ssl certificate\" authority key"
75, tức là tiếng Tây Ban Nha, là ngôn ngữ xác định mã thông báo, xuất phát và dừng các từ:db.articles.createIndex( { subject: "text" } )
5Mẹo
Biểu thức
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
"\"ssl certificate\" authority key"
77. Xem ngôn ngữ tìm kiếm văn bản cho các ngôn ngữ được hỗ trợ.db.articles.createIndex( { subject: "text" } )
6Toán tử
db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
db.articles.find( { $text: { $search: "coffee" } } )
8. Chỉ số phiên bản 3db.articles.find( { $text: { $search: "coffee" } } )
8 là không nhạy cảm và mở rộng trường hợp không nhạy cảm của nó để bao gồm bảng chữ cái cyrillic cũng như các ký tự có dấu hiệu. Để biết chi tiết, xem Index Index Incent tính không nhạy cảm và chỉ số văn bản không nhạy cảm.db.articles.createIndex( { subject: "text" } )
7Mẹo
Để phù hợp với cụm từ chính xác như một thuật ngữ duy nhất, hãy thoát các trích dẫn.
Các truy vấn sau đây tìm kiếm cụm từ
"\"ssl certificate\" authority key"
66:db.articles.createIndex( { subject: "text" } )
8Truy vấn này trả về các tài liệu chứa cụm từ
"\"ssl certificate\" authority key"
66:{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
Bắt đầu từ MongoDB 4.4, nếu bạn bao gồm biểu thức
"\"ssl certificate\" authority key"
49 trong cả hình chiếu và"\"ssl certificate\" authority key"
48, các tài liệu chiếu và sắp xếp có thể có tên trường khác nhau cho biểu thức.Ví dụ: trong thao tác sau, phép chiếu sử dụng một trường có tên
db.articles.createIndex( { subject: "text" } )
03 cho biểu thức và"\"ssl certificate\" authority key"
48 sử dụng trường có têndb.articles.createIndex( { subject: "text" } )
13.db.articles.createIndex( { subject: "text" } )
9Trong các phiên bản trước của MongoDB, nếu
"\"ssl certificate\" authority key"
49 được bao gồm trong cả hình chiếu và sắp xếp, bạn phải chỉ định cùng tên trường cho biểu thức.
Trong MongoDB 4.2, để sắp xếp theo điểm văn bản, bao gồm cùng một biểu thức
6 trong cả tài liệu trình chiếu và biểu thức sắp xếp. Các truy vấn sau đây tìm kiếm thuật ngữ{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 } { "_id" : 7, "subject" : "coffee and cream", "author" : "efg", "views" : 10 } { "_id" : 1, "subject" : "coffee", "author" : "xyz", "views" : 50 } { "_id" : 3, "subject" : "Baking a cake", "author" : "abc", "views" : 90 } { "_id" : 4, "subject" : "baking", "author" : "xyz", "views" : 100 } "\"ssl certificate\" authority key"
55 và sắp xếp kết quả theo điểm giảm dần:same
6 expression in both the projection document and the sort expression. The following query searches for the term{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 } { "_id" : 7, "subject" : "coffee and cream", "author" : "efg", "views" : 10 } { "_id" : 1, "subject" : "coffee", "author" : "xyz", "views" : 50 } { "_id" : 3, "subject" : "Baking a cake", "author" : "abc", "views" : 90 } { "_id" : 4, "subject" : "baking", "author" : "xyz", "views" : 100 } "\"ssl certificate\" authority key"
55 and sorts the results by the descending score:
0db.articles.insertMany( [ { _id: 1, subject: "coffee", author: "xyz", views: 50 }, { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, { _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, { _id: 4, subject: "baking", author: "xyz", views: 100 }, { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, { _id: 6, subject: "Сырники", author: "jkl", views: 80 }, { _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } ] ) Truy vấn trả về các tài liệu phù hợp được sắp xếp theo điểm số giảm dần.
Mẹo
Xem thêm:
Sử dụng phương thức
db.articles.createIndex( { subject: "text" } )
17 kết hợp với"\"ssl certificate\" authority key"
48 để trả về các tài liệu phù hợpdb.articles.createIndex( { subject: "text" } )
19 hàng đầu.Các truy vấn sau đây tìm kiếm thuật ngữ
"\"ssl certificate\" authority key"
55 và sắp xếp kết quả theo điểm giảm dần, giới hạn kết quả đối với hai tài liệu phù hợp hàng đầu:db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |
Mẹo
Xem thêm:
Sử dụng phương thức
db.articles.createIndex( { subject: "text" } )
17 kết hợp với"\"ssl certificate\" authority key"
48 để trả về các tài liệu phù hợpdb.articles.createIndex( { subject: "text" } )
19 hàng đầu.db.articles.insertMany( [ |
{ _id: 1, subject: "coffee", author: "xyz", views: 50 }, |
{ _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 }, |
{ _id: 3, subject: "Baking a cake", author: "abc", views: 90 }, |
{ _id: 4, subject: "baking", author: "xyz", views: 100 }, |
{ _id: 5, subject: "Café Con Leche", author: "abc", views: 200 }, |
{ _id: 6, subject: "Сырники", author: "jkl", views: 80 }, |
{ _id: 7, subject: "coffee and cream", author: "efg", views: 10 }, |
{ _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 } |
] ) |