Hướng dẫn contains mongodb - chứa mongodb

Tài liệu về nhà → Hướng dẫn sử dụng MongoDBMongoDB Manual

Show

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 }
] )
3 để triển khai tự quản lý.
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 for self-managed deployments.

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
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 Thực hiện tìm kiếm văn bản trên nội dung của các trường được lập chỉ mục với chỉ mục văn bản. 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 }
] )
3 có cú pháp sau:
Hướng dẫn contains mongodb - chứa mongodb

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:

{
$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 }
] )
3 chấp nhận tài liệu truy vấn văn bản với các trường 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 }
] )
3
operator accepts a text query document with the following fields:

Đồng ruộng

Loại hình

Sự mô 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 }
] )
8

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.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 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.Behavior for more information on the field.

db.articles.find( { $text: { $search: "coffee" } } )

0

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.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 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" } } )

2

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" } } )

4

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ọn

db.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ục

db.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.

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, 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.

  • 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 }
    ] )
    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.

  • Một truy vấn có thể chỉ định, nhiều nhất là một 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 }
    ] )
    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 in
    { _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.

  • 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 }
    ] )
    3 không thể xuất hiện trong các biểu thứ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.
    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 in
    { _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 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.

  • 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 }
    ] )
    3 không thể xuất hiện trong các biểu thức truy vấn
    { _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 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.
    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 in an
    { _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 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.

  • Để sử dụ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 }
    ] )
    3 trong biểu thứ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 }
    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.
    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 expression.

  • 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
    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.
    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.

  • 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
    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.
    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 combine
    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 with the

    db.articles.find( { $text: { $search: "bake coffee cake" } } )

    6 operator.

  • Bạn không thể kết hợp 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 }
    ] )
    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ứ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 }
    ] )
    3 với toán tử

    db.articles.find( { $text: { $search: "bake coffee cake" } } )

    6.

Lượt xem không hỗ trợ tìm kiế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 operator in aggregation, the following restrictions also apply.

  • Nếu sử dụ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 }
    ] )
    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.

  • Giai đoạn

    db.articles.find( { $text: { $search: "bake coffee cake" } } )

    8 bao gồ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 }
    ] )
    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.

  • Một 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 }
    ] )
    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 in
    { _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 or
    { "_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 expressions.

  • Biểu thức 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 }
    ] )
    3 không thể xuất hiện trong các biểu thứ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 }
    8 hoặc
    { "_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.

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 }
4 trong giai đoạn
{ "_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 }
5.
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 parses and uses to query the text index.

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 }
] )
8, chỉ định một chuỗi các từ 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 }
] )
3 phân tích cú pháp và sử dụng để truy vấn chỉ mục 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
operator treats most punctuation in the string as delimiters, except a hyphen-minus (
{ "_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 }
9) that negates term or an escaped double quotes

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 }] )3 xử lý hầu hết các dấu chấm câu trong chuỗi dưới dạng các trình phân cách, ngoại trừ một dấu gạch nối ({ "_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 }9) phủ nhận thuật ngữ hoặc một trích dẫn kép thoát ra db.articles.find( { $text: { $search: "\"coffee shop\"" } } )0 chỉ định một cụm từ.

Ghi chú

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 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 }
] )
8 aggregation stage performs full-text search on specified fields and is only available on MongoDB Atlas.

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 }
] )
8 cho 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 }
] )
3 khác với giai đoạn tổng hợp tìm kiếm $ do Atlas Search cung cấp. Giai đoạn tổng hợp ____38 thực hiện tìm kiếm toàn văn trên các trường được chỉ định và chỉ có sẵn trên Atlas MongoDB.

Để 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 }
] )
8 bao gồm một cụm từ và các thuật ngữ riêng lẻ, tìm kiếm văn bản sẽ chỉ khớp với các tài liệu bao gồm cụm từ.

"\"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 }
] )
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 }
] )
3
operator searches for the phrase

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 }
] )
3 tìm kiếm cụm từ

db.articles.find( { $text: { $search: "\"coffee shop\"" } } )

8.

  • Tiền tố một từ có dấu gạch nối (

    { "_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 }
    9) 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ả.

  • 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ử
    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 sẽ coi dấu gạch nối (
    { "_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 }
    9) là một dấu phân cách. Để phủ nhận từ

    { "_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.
    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 treats the hyphen-minus (
    { "_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 }
    9) as a delimiter. To negate the word

    { "_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 }
] )
3 thêm tất cả các phủ định vào truy vấn với toán tử logic

{ "_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 }
] )
3
operator adds all negations to the query with the logical

{ "_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 }
] )
3 bỏ qua các từ dừng cụ thể về ngôn ngữ, chẳng hạn như

"\"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 }
] )
3
operator ignores language-specific stop words, such as

"\"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 }
] )
3 khớp với từ gốc hoàn chỉnh. Vì vậy, nếu một trường tài liệu chứa từ

"\"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 }
] )
3
operator matches on the complete stemmed word. So if a document field contains the word

"\"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 }
] )
3 khớp với từ chính xác.case sensitive search (i.e.

"\"ssl certificate\" authority key"

07), if the suffix stem contains uppercase letters, 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 }
] )
3
operator matches on the exact word.

Đố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 }
] )
3 khớp với từ chính xác.diacritic sensitive search (i.e.

"\"ssl certificate\" authority key"

09), if the suffix stem contains the diacritic mark or marks, 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 }
] )
3
operator matches on the exact word.

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 }
] )
3 mặc định là sự vô cảm của trường hợp của chỉ mục 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
operator defaults to the case insensitivity of the text index:

  • 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 }
] )
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
operator:

  • Đầ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 }
    ] )
    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.

Đố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 }
] )
3 khớp với từ chính xá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 }
] )
3
operator matches on the exact word.

Đố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 }
] )
3 khớp với từ chính xác.

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 }] )3 mặc định là sự vô cảm của trường hợp của chỉ mục văn bản:

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 }
] )
3
operator defaults to the diacritic insensitivity of the text index:

  • Để 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 }
    ] )
    3:

Đầ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 }
] )
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
operator has no effect with earlier versions of the

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 }
] )
3
operator:

  • Mẹo

  • Xem thê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 }
    ] )
    3 query operation includes an additional stage to filter out the documents that do not match.

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 }
] )
3 mặc định là sự vô cảm của chỉ mục văn bản:

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 }
] )
3
operator searches the

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 }
] )
3
operator matches on the exact word.

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 }] )3 mặc định là sự vô cảm của trường hợp của chỉ mục văn bản:

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 }
] )
3
operator assigns a score to each document that contains the search term in the indexed fields. The score represents the relevance of a document to a given text search query. The score can be part of a

"\"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 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 }
] )
3
operation. See
{ "_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 projection operator for details on accessing the score for projection or sort.

Để 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 }
] )
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.

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 }
] )
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.

{ _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 }
] )
3 sẽ thực hiện tìm kiếm logic
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 trên mỗi thuật ngữ và trả về các tài liệu chứa bất kỳ điều khoản nào.
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 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 }
] )
9 search on each term and returns documents that contains any of the terms.

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 }
] )
8 gồm ba thuật ngữ được phân định theo không gian,

"\"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 }
9. 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 }
] )
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 }
] )
3
operator will exclude the documents that contain those terms from the results.

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"

0

Truy vấn trả về các tài liệu sau:

"\"ssl certificate\" authority key"

1

Mẹo

Sử dụng trường

db.articles.find( { $text: { $search: "coffee" } } )

0 tùy chọn trong 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 }
] )
3 để chỉ định ngôn ngữ xác định danh sách các từ dừng và các quy tắc cho stemmer và tokenizer cho chuỗi tìm kiế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 }
] )
3
expression to specify a language that determines the list of stop words and the rules for the stemmer and tokenizer for the search string.

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"

2

Truy vấn trả về các tài liệu sau:

"\"ssl certificate\" authority key"

3

Sử dụng trường

db.articles.find( { $text: { $search: "coffee" } } )

0 tùy chọn trong 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 }
] )
3 để chỉ định ngôn ngữ xác định danh sách các từ dừng và các quy tắc cho stemmer và tokenizer cho chuỗi tìm kiế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 }
] )
3
expression can also accept the language by name,

"\"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 }
9. 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 }
] )
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 }
] )
3
operator defers to the case and diacritic insensitivity of the

db.articles.find( { $text: { $search: "coffee" } } )

6 index. The version 3

db.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"

4

Truy vấn trả về các tài liệu sau:

"\"ssl certificate\" authority key"

5

Sử dụng trường

db.articles.find( { $text: { $search: "coffee" } } )

0 tùy chọn trong 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 }
] )
3 để chỉ định ngôn ngữ xác định danh sách các từ dừng và các quy tắc cho stemmer và tokenizer cho chuỗi tìm kiếm.

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"

6

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 }
] )
3 cũng có thể chấp nhận ngôn ngữ theo tên,

"\"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"

7

Mẹ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 }
] )
3 bảo vệ trường hợp và sự không nhạy cảm của chỉ số

db.articles.find( { $text: { $search: "coffee" } } )

6. Chỉ số phiên bản 3

db.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"

8

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 }
] )
3 cũng có thể chấp nhận ngôn ngữ theo tên,

"\"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"

9

Mẹ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 }
] )
3 bảo vệ trường hợp và sự không nhạy cảm của chỉ số

db.articles.find( { $text: { $search: "coffee" } } )

6. Chỉ số phiên bản 3

db.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 }
] )
3
operator will exclude the documents that contain those terms from the results. You can also specify case sensitivity for negated terms.

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" } )

0

Sử 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" } )

1

Mẹ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" } )

2

Truy 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" } )

3

Mẹo

Tìm kiếm chỉ khớp với tài liệ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 }
] )
3 operator will exclude the documents that contain those terms from the results.

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" } )

4

Sử 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" } )

5

Mẹ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" } )

7

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 }
    9. 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 }
    ] )
    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.createIndex( { subject: "text" } )

    8

    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" } )

    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ên

    db.articles.createIndex( { subject: "text" } )

    11.

    db.articles.createIndex( { subject: "text" } )

    9

    Trong 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

    { "_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 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ữ

    "\"ssl certificate\" authority key"

    53 và sắp xếp kết quả theo điểm giảm dần:same
    { "_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 expression in both the projection document and the sort expression. The following query searches for the term

    "\"ssl certificate\" authority key"

    53 and sorts the results by the descending score:

    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 }
    ] )
    0

    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ợp

db.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 }
] )
1

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ợp

db.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 }
] )
2

Mẹo

Xem thêm: