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.
Trang này mô tả 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 } |
] ) |
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 } |
] ) |
3 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 } ] )
3 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" } } ) | 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
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" } } ) 1, 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" } } ) 3; 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" } } ) 3; tức là tìm kiếm bảo vệ sự không nhạy cảm của chỉ sốdb.articles.find( { $text: { $search: "coffee" } } ) 6.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" } } ) 6 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" } } ) 4 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" } } ) 6.Diacritic Insensitivity. |
Để biết thêm thông tin, hãy xem sự vô cảm của Diacritic.
3 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ử
3, 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 } ] )
3 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
3.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 } ] )
3 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 } ] )
3 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
3 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 } ] )
3.{ _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 }
3 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 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 }
5 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
3 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 } ] )
5 hoặc các biểu thức 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 }
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 }
3 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 } ] )
8 expression, all clauses in the{ _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 }
8 array must be indexed.{ _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 } Để sử dụng truy vấn
3 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 } ] )
8, tất cả các mệnh đề trong mảng{ _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 }
8 phải được lập chỉ mục.{ _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 }
3 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" } } )
0 nếu truy vấn bao gồm biểu thức truy vấn
3.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 } ] )
3 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" } } )
2 nếu truy vấn bao gồm biểu thức
3.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 } ] )
3 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 } ] )
3 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" } } )
6 operator.Bạn không thể kết hợp biểu thức
3, 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 } ] )
3 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" } } )
6.
Lượt xem không hỗ trợ tìm kiếm văn bản.
3 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ử
3 trong tập hợp, các hạn chế sau đây 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 } ] )
3 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
db.articles.find( { $text: { $search: "bake coffee cake" } } )
8 bao gồm
3 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 } ] )
3 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ử
3 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 } ] )
3 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 } ] )
8 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 }
3 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ử
3 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 } ] )
8 hoặc{ _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 }
3.{ "_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 } |
] ) |
{ "_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.find( { $text: { $search: "\"coffee shop\"" } } )
0 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 } |
] ) |
{ "_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.find( { $text: { $search: "\"coffee shop\"" } } )
0 chỉ định một cụm từ.Ghi chú
3 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ữ riêng lẻ, gửi lại cụm từ trong trích dẫn kép thoát (
db.articles.find( { $text: { $search: "\"coffee shop\"" } } )
0), 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 } |
] ) |
db.articles.find( { $text: { $search: "\"coffee shop\"" } } )
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 } |
] ) |
db.articles.find( { $text: { $search: "\"coffee shop\"" } } )
8.Tiền tố một từ có dấu gạch nối (
9) phủ nhận một từ:{ "_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ừ phủ định loại trừ các tài liệu chứa từ phủ định từ tập kết quả.
Một từ gạch nối, chẳng hạn như
{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
0, không phải là một phủ định. Nếu được sử dụng trong một từ Hyphenated, toán tử
3 sẽ coi dấu gạch nố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 } ] )
9) là một dấu phân cách. Để phủ nhận từ{ "_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 }
3 trong trường hợp này, bao gồm một khoảng trống giữa{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
4 và{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
5, tức là,{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
6.
3 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 } ] )
9) as a delimiter. To negate the word{ "_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 }
3 in this instance, include a space between{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
4 and{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
5, i.e.,{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
6.
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 }
8.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 }
8 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"
00 và"\"ssl certificate\" authority key"
01 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"
00 and"\"ssl certificate\" authority key"
01 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"
03, một tìm kiếm trên thuật ngữ"\"ssl certificate\" authority key"
04 sẽ không khớp. Tuy nhiên,"\"ssl certificate\" authority key"
03 hoặc"\"ssl certificate\" authority key"
06 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"
03, a search on the term"\"ssl certificate\" authority key"
04 will not match. However,"\"ssl certificate\" authority key"
03 or"\"ssl certificate\" authority key"
06 will match.Đối với tìm kiếm nhạy cảm trường hợp (nghĩa là
"\"ssl certificate\" authority key"
07), 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"
07), 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 diarritic (nghĩa là
"\"ssl certificate\" authority key"
09), nếu thân hậu tố chứa dấu hoặc dấu hiệu Diacritic, 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 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" } } )
6 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"
13.
Để hỗ trợ tìm kiếm nhạy cảm trường hợp trong đó chỉ số
db.articles.find( { $text: { $search: "coffee" } } )
6 không nhạy cảm với trường hợp, chỉ định"\"ssl certificate\" authority key"
07.Khi thực hiện tìm kiếm nhạy cảm trường hợp (
"\"ssl certificate\" authority key"
07) trong đó chỉ sốdb.articles.find( { $text: { $search: "coffee" } } )
6 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" } } )
6 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, hoạt động truy vấn
3 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 } ] )
3 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"
07), 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 diarritic (nghĩa là
"\"ssl certificate\" authority key"
09), nếu thân hậu tố chứa dấu hoặc dấu hiệu Diacritic, 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" } } )
6 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"
13.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" } } )
6 không nhạy cảm với trường hợp, chỉ định"\"ssl certificate\" authority key"
07.Khi thực hiện tìm kiếm nhạy cảm trường hợp (
"\"ssl certificate\" authority key"
07) trong đó chỉ sốdb.articles.find( { $text: { $search: "coffee" } } )
6 không nhạy cảm, toán tử
3: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" } } )
6 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, hoạt động 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" } } )
6 index.Chỉ định
"\"ssl certificate\" authority key"
07 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:
3 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"
25,"\"ssl certificate\" authority key"
26 và"\"ssl certificate\" authority key"
27.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" } } )
6 index, which is diacritic sensitive.Các phiên bản trước đó của chỉ số
db.articles.find( { $text: { $search: "coffee" } } )
6 rất nhạy cảm với dấu hiệ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 } |
] ) |
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" } } )
6 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"
13.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"
46 method specification as well as part of the projection expression. The"\"ssl certificate\" authority key"
47 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" } } )
6 không nhạy cảm với trường hợp, chỉ định"\"ssl certificate\" authority key"
07.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"
07) trong đó chỉ sốdb.articles.find( { $text: { $search: "coffee" } } )
6 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" } } )
6 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, hoạt động 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 } |
Mẹo
Nếu chuỗi tìm kiếm là một chuỗi được phân phối không gian, thì 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 } |
] ) |
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 } |
] ) |
Truy vấn sau đây chỉ định 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"
59: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"
60 hoặc"\"ssl certificate\" authority key"
53 hoặc"\"ssl certificate\" authority key"
62 trong trường"\"ssl certificate\" authority key"
51 đượ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"
53 or"\"ssl certificate\" authority key"
62 in the indexed"\"ssl certificate\" authority key"
51 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"
64: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"
64:{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
Mẹo
Xem thêm:
Một thuật ngữ phủ định là một thuật ngữ được đặt trước một dấu hiệu trừ
{ "_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 } |
] ) |
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"
53 nhưng không chứa thuật ngữ"\"ssl certificate\" authority key"
69, hay chính xác hơn là phiên bản gốc của các từ:not contain the term"\"ssl certificate\" authority key"
69, or more precisely the stemmed version of the words:"\"ssl certificate\" authority key"
0Truy vấn trả về các tài liệu sau:
"\"ssl certificate\" authority key"
1Mẹo
Sử dụng trường
db.articles.find( { $text: { $search: "coffee" } } )
0 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" } } )
1, 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.Truy vấn sau đây chỉ định
"\"ssl certificate\" authority key"
73, 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ừ:"\"ssl certificate\" authority key"
2Truy vấn trả về các tài liệu sau:
"\"ssl certificate\" authority key"
3Sử dụng trường
db.articles.find( { $text: { $search: "coffee" } } )
0 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 } |
] ) |
"\"ssl certificate\" authority key"
75. See Text Search Languages for the supported languages.Mẹo
Xem thêm:
Một thuật ngữ phủ định là một thuật ngữ được đặt trước một dấu hiệu trừ
{ "_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 } |
] ) |
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" } } )
6 index. The version 3db.articles.find( { $text: { $search: "coffee" } } )
6 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.Ví dụ sau đây tìm kiếm các tài liệu chứa các từ
"\"ssl certificate\" authority key"
53 nhưng không chứa thuật ngữ"\"ssl certificate\" authority key"
69, hay chính xác hơn là phiên bản gốc của các từ:"\"ssl certificate\" authority key"
4Truy vấn trả về các tài liệu sau:
"\"ssl certificate\" authority key"
5Sử dụng trường
db.articles.find( { $text: { $search: "coffee" } } )
0 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 } |
] ) |
Mẹo
Nếu bạn chỉ định giá trị ngôn ngữ là
db.articles.find( { $text: { $search: "coffee" } } )
1, 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.Truy vấn sau đây chỉ định
"\"ssl certificate\" authority key"
73, 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ừ:"\"ssl certificate\" authority key"
6Biể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"
75. Xem ngôn ngữ tìm kiếm văn bản cho các ngôn ngữ được hỗ trợ."\"ssl certificate\" authority key"
7Mẹo
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" } } )
6. Chỉ số phiên bản 3db.articles.find( { $text: { $search: "coffee" } } )
6 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."\"ssl certificate\" authority key"
8Biể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"
75. Xem ngôn ngữ tìm kiếm văn bản cho các ngôn ngữ được hỗ trợ."\"ssl certificate\" authority key"
9Mẹo
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" } } )
6. Chỉ số phiên bản 3db.articles.find( { $text: { $search: "coffee" } } )
6 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.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 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"
79 hoặc"\"ssl certificate\" authority key"
80:not contain the lower-case term"\"ssl certificate\" authority key"
69, or more precisely the stemmed version of the words:db.articles.createIndex( { subject: "text" } )
0Sử dụng chỉ mục phiên bản 3
db.articles.find( { $text: { $search: "coffee" } } )
6, truy vấn phù hợp với các tài liệu sau.db.articles.createIndex( { subject: "text" } )
1Mẹo
Với các phiên bản trước của chỉ mục
db.articles.find( { $text: { $search: "coffee" } } )
6, truy vấn sẽ không khớp với bất kỳ tài liệu nào.Để cho phép tìm kiếm nhạy cảm trường hợp, chỉ định
"\"ssl certificate\" authority key"
07. Chỉ định"\"ssl certificate\" authority key"
07 có thể ảnh hưởng đến hiệu suất.db.articles.createIndex( { subject: "text" } )
2Truy vấn sau đây thực hiện tìm kiếm nhạy cảm trường hợp cho thuật ngữ
"\"ssl certificate\" authority key"
85:db.articles.createIndex( { subject: "text" } )
3Mẹo
Tìm kiếm chỉ khớp với tài liệu:
3
operator will exclude the documents that contain those terms from the results.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 sau đây thực hiện tìm kiếm nhạy cảm trường hợp cho cụm từ
"\"ssl certificate\" authority key"
86:db.articles.createIndex( { subject: "text" } )
4Sử dụng chỉ mục phiên bản 3
db.articles.find( { $text: { $search: "coffee" } } )
6, truy vấn phù hợp với các tài liệu sau.db.articles.createIndex( { subject: "text" } )
5Mẹo
Với các phiên bản trước của chỉ mục
db.articles.find( { $text: { $search: "coffee" } } )
6, truy vấn sẽ không khớp với bất kỳ tài liệu nào.db.articles.createIndex( { subject: "text" } )
6Để cho phép tìm kiếm nhạy cảm trường hợp, chỉ định
"\"ssl certificate\" authority key"
07. Chỉ định"\"ssl certificate\" authority key"
07 có thể ảnh hưởng đến hiệu suất.db.articles.createIndex( { subject: "text" } )
7Mẹo
Xem thêm:
Một thuật ngữ phủ định là một thuật ngữ được đặt trước một dấu hiệu trừ
9. Nếu bạn phủ nhận một thuật ngữ, toán tử{ "_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 }
3 sẽ loại trừ các tài liệu có chứa các thuật ngữ đó khỏi kết quả.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.createIndex( { subject: "text" } )
8Do đó, 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" } )
04.Trong các phiên bản trước, để bao gồm biểu thức
"\"ssl certificate\" authority key"
47 trong"\"ssl certificate\" authority key"
46, bạn cũng phải bao gồm cùng một biểu thức trong phép chiếu.Bắt đầu từ MongoDB 4.4, nếu bạn bao gồm biểu thức
"\"ssl certificate\" authority key"
47 trong cả hình chiếu và"\"ssl certificate\" authority key"
46, 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" } )
01 cho biểu thức và"\"ssl certificate\" authority key"
46 sử dụng trường có têndb.articles.createIndex( { subject: "text" } )
11.db.articles.createIndex( { subject: "text" } )
9Trong các phiên bản trước của MongoDB, nếu
"\"ssl certificate\" authority key"
47 đượ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
4 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"
53 và sắp xếp kết quả theo điểm giảm dần:same
4 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"
53 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" } )
15 kết hợp với"\"ssl certificate\" authority key"
46 để trả về các tài liệu phù hợpdb.articles.createIndex( { subject: "text" } )
17 hàng đầu.Các truy vấn sau đây tìm kiếm thuật ngữ
"\"ssl certificate\" authority key"
53 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" } )
15 kết hợp với"\"ssl certificate\" authority key"
46 để trả về các tài liệu phù hợpdb.articles.createIndex( { subject: "text" } )
17 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 } |
] ) |