Hướng dẫn regex mongodb aggregation - regex mongodb tổng hợp

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

db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
7
Hướng dẫn regex mongodb aggregation - regex mongodb tổng hợp

Mới trong phiên bản 4.2.

Thực hiện khớp mẫu biểu thức thông thường (Regex) và trả về:

  • db.myColl.insertMany([
    { _id: 1, category: "café" },
    { _id: 2, category: "cafe" },
    { _id: 3, category: "cafE" }
    ])
    8 Nếu một trận đấu tồn tại.

  • db.myColl.insertMany([
    { _id: 1, category: "café" },
    { _id: 2, category: "cafe" },
    { _id: 3, category: "cafE" }
    ])
    9 Nếu một trận đấu không tồn tại.

MongoDB sử dụng các biểu thức thông thường tương thích Perl (tức là "PCRE") phiên bản 8.41 với hỗ trợ UTF-8.

Trước MongoDB 4.2, đường ống tổng hợp chỉ có thể sử dụng toán tử truy vấn

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

0 trong giai đoạn

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

1. Để biết thêm thông tin về việc sử dụng Regex trong truy vấn, xem

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

0

Toán tử

db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
7 có cú pháp sau:
db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
7
operator has the following syntax:

{ $regexMatch: { input: , regex: , options: } }

Đồng ruộng

Sự mô tả

đầu vào

Chuỗi mà bạn muốn áp dụng mẫu regex. Có thể là một chuỗi hoặc bất kỳ biểu thức hợp lệ nào được giải quyết thành một chuỗi.regex pattern. Can be a string or any valid expression that resolves to a string.

REGEX

Các mẫu regex để áp dụng. Có thể là bất kỳ biểu thức hợp lệ nào được giải quyết thành một chuỗi hoặc mẫu regex

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

4. Khi sử dụng regex

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

4, bạn cũng có thể chỉ định các tùy chọn regex

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

6 và

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

7 (nhưng không phải là tùy chọn

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

8 hoặc

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

9):

  • { "_id" : 1, "category" : "café" }
    { "_id" : 2, "category" : "cafe" }
    { "_id" : 3, "category" : "cafE" }
    0

  • db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

    4

  • { "_id" : 1, "category" : "café" }
    { "_id" : 2, "category" : "cafe" }
    { "_id" : 3, "category" : "cafE" }
    2

Ngoài ra, bạn cũng có thể chỉ định các tùy chọn Regex với trường Tùy chọn. Để chỉ định các tùy chọn

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

8 hoặc

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

9, bạn phải sử dụng trường Tùy chọn.options field. To specify the

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

8 or

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

9 options, you must use the options field.

Bạn không thể chỉ định các tùy chọn trong cả trường

{ "_id" : 1, "category" : "café" }
{ "_id" : 2, "category" : "cafe" }
{ "_id" : 3, "category" : "cafE" }
5 và
{ "_id" : 1, "category" : "café" }
{ "_id" : 2, "category" : "cafe" }
{ "_id" : 3, "category" : "cafE" }
6.

tùy chọn

Không bắt buộc. Các

{ "_id" : 1, "category" : "café" }
{ "_id" : 2, "category" : "cafe" }
{ "_id" : 3, "category" : "cafE" }
7 sau đây có sẵn để sử dụng với biểu thức thông thường.

Ghi chú

Bạn không thể chỉ định các tùy chọn trong cả trường

{ "_id" : 1, "category" : "café" }
{ "_id" : 2, "category" : "cafe" }
{ "_id" : 3, "category" : "cafE" }
5 và
{ "_id" : 1, "category" : "café" }
{ "_id" : 2, "category" : "cafe" }
{ "_id" : 3, "category" : "cafE" }
6.

tùy chọn

Sự mô tả

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

6

đầu vào

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

7

Chuỗi mà bạn muốn áp dụng mẫu regex. Có thể là một chuỗi hoặc bất kỳ biểu thức hợp lệ nào được giải quyết thành một chuỗi.

REGEX

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

9

Các mẫu regex để áp dụng. Có thể là bất kỳ biểu thức hợp lệ nào được giải quyết thành một chuỗi hoặc mẫu regex

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

4. Khi sử dụng regex

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

4, bạn cũng có thể chỉ định các tùy chọn regex

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

6 và

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

7 (nhưng không phải là tùy chọn

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

8 hoặc

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

9):

Ngoài ra, bạn cũng có thể chỉ định các tùy chọn Regex với trường Tùy chọn. Để chỉ định các tùy chọn

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

8 hoặc

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

9, bạn phải sử dụng trường Tùy chọn.

Bạn không thể chỉ định các tùy chọn trong cả trường

{ "_id" : 1, "category" : "café" }
{ "_id" : 2, "category" : "cafe" }
{ "_id" : 3, "category" : "cafE" }
5 và
{ "_id" : 1, "category" : "café" }
{ "_id" : 2, "category" : "cafe" }
{ "_id" : 3, "category" : "cafE" }
6.

tùy chọn

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

8

Không bắt buộc. Các

{ "_id" : 1, "category" : "café" }
{ "_id" : 2, "category" : "cafe" }
{ "_id" : 3, "category" : "cafE" }
7 sau đây có sẵn để sử dụng với biểu thức thông thường.

tùy chọn

Để cho phép ký tự DOT (nghĩa là

{ "_id" : 1, "category" : "café", "results" : false }
{ "_id" : 2, "category" : "cafe", "results" : true }
{ "_id" : 3, "category" : "cafE", "results" : false }
2) trong mẫu để khớp với tất cả các ký tự bao gồm ký tự dòng mới, bao gồm tùy chọn S trong trường Tùy chọn:

  • Ví dụ sau đây bao gồm tùy chọn

    db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

    8 để cho phép ký tự DOT (tức là.) Để khớp với tất cả các ký tự bao gồm dòng mới cũng như tùy chọn

    db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

    6 để thực hiện phù hợp không nhạy cảm với trường hợp:

  • Tạo một bộ sưu tập mẫu

    db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

    02 với các tài liệu sau:

Tập hợp sau đây sử dụng db.myColl.insertMany([ { _id: 1, category: "café" }, { _id: 2, category: "cafe" }, { _id: 3, category: "cafE" }])7 để kiểm tra xem trường db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )04 có chứa địa chỉ email với db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )05 không và phân loại phản hồi là db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )06 hoặc db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )07.

Ví dụ sau đây bao gồm tùy chọn

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

8 để cho phép ký tự DOT (tức là.) Để khớp với tất cả các ký tự bao gồm dòng mới cũng như tùy chọn

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

6 để thực hiện phù hợp không nhạy cảm với trường hợp: ignores the collation specified for the collection,
{ "_id" : 1, "category" : "café", "results" : false }
{ "_id" : 2, "category" : "cafe", "results" : true }
{ "_id" : 3, "category" : "cafE", "results" : false }
7, and the index, if used.

Tạo một bộ sưu tập mẫu

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

02 với các tài liệu sau:

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

Tập hợp sau đây sử dụng

db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
7 để kiểm tra xem trường

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

04 có chứa địa chỉ email với

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

05 không và phân loại phản hồi là

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

06 hoặc

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

07.

db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])

Hoạt động trả về các tài liệu sau:

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
7 bỏ qua đối chiếu được chỉ định cho bộ sưu tập,
{ "_id" : 1, "category" : "café", "results" : false }
{ "_id" : 2, "category" : "cafe", "results" : true }
{ "_id" : 3, "category" : "cafE", "results" : false }
7 và chỉ số, nếu được sử dụng.

{ "_id" : 1, "category" : "café" }
{ "_id" : 2, "category" : "cafe" }
{ "_id" : 3, "category" : "cafE" }

Ví dụ, việc tạo một bộ sưu tập mẫu với cường độ đối chiếu

{ "_id" : 1, "category" : "café", "results" : false }
{ "_id" : 2, "category" : "cafe", "results" : true }
{ "_id" : 3, "category" : "cafE", "results" : false }
8 (nghĩa là chỉ so sánh ký tự cơ sở và bỏ qua các khác biệt khác như trường hợp và dấu hiệu):
db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
7
ignores collation; that is, the following regular expression pattern matching examples are case-sensitive and diacritic sensitive:

db.myColl.aggregate( [ { $addFields: { results: { $regexMatch: { input: "$category", regex: /cafe/ } } } } ] )
db.myColl.aggregate(
[ { $addFields: { results: { $regexMatch: { input: "$category", regex: /cafe/ } } } } ],
{ collation: { locale: "fr", strength: 1 } } // Ignored in the $regexMatch
)

Chèn các tài liệu sau:

{ "_id" : 1, "category" : "café", "results" : false }
{ "_id" : 2, "category" : "cafe", "results" : true }
{ "_id" : 3, "category" : "cafE", "results" : false }

Sử dụng đối chiếu của bộ sưu tập, thao tác sau đây thực hiện một trận đấu không nhạy cảm với trường hợp và không nhạy cảm với các trường hợp:

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

6 Option instead. See

db.myColl.aggregate( [ { $match: { category: "cafe" } } ] )

6 Option
for an example.

Để minh họa hành vi của toán tử

db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
7 như đã thảo luận trong ví dụ này, hãy tạo một bộ sưu tập mẫu
db.products.insertMany([
{ _id: 1, description: "Single LINE description." },
{ _id: 2, description: "First lines\nsecond line" },
{ _id: 3, description: "Many spaces before line" },
{ _id: 4, description: "Multiple\nline descriptions" },
{ _id: 5, description: "anchors, links and hyperlinks" },
{ _id: 6, description: "métier work vocation" }
])
3 với các tài liệu sau:
db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
7
operator as discussed in this example, create a sample collection
db.products.insertMany([
{ _id: 1, description: "Single LINE description." },
{ _id: 2, description: "First lines\nsecond line" },
{ _id: 3, description: "Many spaces before line" },
{ _id: 4, description: "Multiple\nline descriptions" },
{ _id: 5, description: "anchors, links and hyperlinks" },
{ _id: 6, description: "métier work vocation" }
])
3 with the following documents:

db.products.insertMany([
{ _id: 1, description: "Single LINE description." },
{ _id: 2, description: "First lines\nsecond line" },
{ _id: 3, description: "Many spaces before line" },
{ _id: 4, description: "Multiple\nline descriptions" },
{ _id: 5, description: "anchors, links and hyperlinks" },
{ _id: 6, description: "métier work vocation" }
])

Theo mặc định,

db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
7 thực hiện một trận đấu nhạy cảm trường hợp. Ví dụ: tập hợp sau đây thực hiện
db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
7 nhạy cảm với trường hợp trên trường
db.products.insertMany([
{ _id: 1, description: "Single LINE description." },
{ _id: 2, description: "First lines\nsecond line" },
{ _id: 3, description: "Many spaces before line" },
{ _id: 4, description: "Multiple\nline descriptions" },
{ _id: 5, description: "anchors, links and hyperlinks" },
{ _id: 6, description: "métier work vocation" }
])
6. Mẫu regex
db.products.insertMany([
{ _id: 1, description: "Single LINE description." },
{ _id: 2, description: "First lines\nsecond line" },
{ _id: 3, description: "Many spaces before line" },
{ _id: 4, description: "Multiple\nline descriptions" },
{ _id: 5, description: "anchors, links and hyperlinks" },
{ _id: 6, description: "métier work vocation" }
])
7 không chỉ định bất kỳ nhóm nào:
db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
7
performs a case-sensitive match. For example, the following aggregation performs a case-sensitive
db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
7
on the
db.products.insertMany([
{ _id: 1, description: "Single LINE description." },
{ _id: 2, description: "First lines\nsecond line" },
{ _id: 3, description: "Many spaces before line" },
{ _id: 4, description: "Multiple\nline descriptions" },
{ _id: 5, description: "anchors, links and hyperlinks" },
{ _id: 6, description: "métier work vocation" }
])
6 field. The regex pattern
db.products.insertMany([
{ _id: 1, description: "Single LINE description." },
{ _id: 2, description: "First lines\nsecond line" },
{ _id: 3, description: "Many spaces before line" },
{ _id: 4, description: "Multiple\nline descriptions" },
{ _id: 5, description: "anchors, links and hyperlinks" },
{ _id: 6, description: "métier work vocation" }
])
7 does not specify any grouping:

db.products.aggregate([
{ $addFields: { result: { $regexMatch: { input: "$description", regex: /line/ } } } }
])

Hoạt động trả về như sau:

{ "_id" : 1, "description" : "Single LINE description.", "result" : false }
{ "_id" : 2, "description" : "First lines\nsecond line", "result" : true }
{ "_id" : 3, "description" : "Many spaces before line", "result" : true }
{ "_id" : 4, "description" : "Multiple\nline descriptions", "result" : true }
{ "_id" : 5, "description" : "anchors, links and hyperlinks", "result" : false }
{ "_id" : 6, "description" : "métier work vocation", "result" : false }

Mẫu Regex sau đây

db.products.insertMany([
{ _id: 1, description: "Single LINE description." },
{ _id: 2, description: "First lines\nsecond line" },
{ _id: 3, description: "Many spaces before line" },
{ _id: 4, description: "Multiple\nline descriptions" },
{ _id: 5, description: "anchors, links and hyperlinks" },
{ _id: 6, description: "métier work vocation" }
])
8 chỉ định nhóm
db.products.insertMany([
{ _id: 1, description: "Single LINE description." },
{ _id: 2, description: "First lines\nsecond line" },
{ _id: 3, description: "Many spaces before line" },
{ _id: 4, description: "Multiple\nline descriptions" },
{ _id: 5, description: "anchors, links and hyperlinks" },
{ _id: 6, description: "métier work vocation" }
])
9 trong mẫu:

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

0

Hoạt động trả về như sau:

Mẫu Regex sau đây

db.products.insertMany([
{ _id: 1, description: "Single LINE description." },
{ _id: 2, description: "First lines\nsecond line" },
{ _id: 3, description: "Many spaces before line" },
{ _id: 4, description: "Multiple\nline descriptions" },
{ _id: 5, description: "anchors, links and hyperlinks" },
{ _id: 6, description: "métier work vocation" }
])
8 chỉ định nhóm
db.products.insertMany([
{ _id: 1, description: "Single LINE description." },
{ _id: 2, description: "First lines\nsecond line" },
{ _id: 3, description: "Many spaces before line" },
{ _id: 4, description: "Multiple\nline descriptions" },
{ _id: 5, description: "anchors, links and hyperlinks" },
{ _id: 6, description: "métier work vocation" }
])
9 trong mẫu:

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )1

Ghi chú

Bạn không thể chỉ định các tùy chọn trong cả trường

{ "_id" : 1, "category" : "café" }
{ "_id" : 2, "category" : "cafe" }
{ "_id" : 3, "category" : "cafE" }
5 và
{ "_id" : 1, "category" : "café" }
{ "_id" : 2, "category" : "cafe" }
{ "_id" : 3, "category" : "cafE" }
6.i option as part of the regex field or in the options field:

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

2

Để thực hiện khớp mẫu không nhạy cảm trường hợp, bao gồm tùy chọn I là một phần của trường regex hoặc trong trường Tùy chọn:

db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
7 on the
db.products.insertMany([
{ _id: 1, description: "Single LINE description." },
{ _id: 2, description: "First lines\nsecond line" },
{ _id: 3, description: "Many spaces before line" },
{ _id: 4, description: "Multiple\nline descriptions" },
{ _id: 5, description: "anchors, links and hyperlinks" },
{ _id: 6, description: "métier work vocation" }
])
6 field. The regex pattern
db.products.insertMany([
{ _id: 1, description: "Single LINE description." },
{ _id: 2, description: "First lines\nsecond line" },
{ _id: 3, description: "Many spaces before line" },
{ _id: 4, description: "Multiple\nline descriptions" },
{ _id: 5, description: "anchors, links and hyperlinks" },
{ _id: 6, description: "métier work vocation" }
])
7 does not specify any grouping:

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

3

Hoạt động trả về các tài liệu sau:

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

4

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } ) (adsbygoogle = window.adsbygoogle || []).push({}); 1

Ghi chú

Bạn không thể chỉ định các tùy chọn trong cả trường

{ "_id" : 1, "category" : "café" }
{ "_id" : 2, "category" : "cafe" }
{ "_id" : 3, "category" : "cafE" }
5 và
{ "_id" : 1, "category" : "café" }
{ "_id" : 2, "category" : "cafe" }
{ "_id" : 3, "category" : "cafE" }
6.m option as part of the regex field or in the options field:

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

5

Để thực hiện khớp mẫu không nhạy cảm trường hợp, bao gồm tùy chọn I là một phần của trường regex hoặc trong trường Tùy chọn:

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

6

Hoạt động trả về như sau:

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

7

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )1

Ghi chú

Bạn không thể chỉ định các tùy chọn trong cả trường

{ "_id" : 1, "category" : "café" }
{ "_id" : 2, "category" : "cafe" }
{ "_id" : 3, "category" : "cafE" }
5 và
{ "_id" : 1, "category" : "café" }
{ "_id" : 2, "category" : "cafe" }
{ "_id" : 3, "category" : "cafE" }
6.s option in the options field:

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

8

Để thực hiện khớp mẫu không nhạy cảm trường hợp, bao gồm tùy chọn I là một phần của trường regex hoặc trong trường Tùy chọn:

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

9

Hoạt động trả về như sau:

db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
0

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )1

Ghi chú

Bạn không thể chỉ định các tùy chọn trong cả trường

{ "_id" : 1, "category" : "café" }
{ "_id" : 2, "category" : "cafe" }
{ "_id" : 3, "category" : "cafE" }
5 và
{ "_id" : 1, "category" : "café" }
{ "_id" : 2, "category" : "cafe" }
{ "_id" : 3, "category" : "cafE" }
6.s option in the options field:

db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
1

Để thực hiện khớp mẫu không nhạy cảm trường hợp, bao gồm tùy chọn I là một phần của trường regex hoặc trong trường Tùy chọn:

db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
2

Hoạt động trả về như sau:

db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
3

Mẫu Regex sau đây

db.products.insertMany([
{ _id: 1, description: "Single LINE description." },
{ _id: 2, description: "First lines\nsecond line" },
{ _id: 3, description: "Many spaces before line" },
{ _id: 4, description: "Multiple\nline descriptions" },
{ _id: 5, description: "anchors, links and hyperlinks" },
{ _id: 6, description: "métier work vocation" }
])
8 chỉ định nhóm
db.products.insertMany([
{ _id: 1, description: "Single LINE description." },
{ _id: 2, description: "First lines\nsecond line" },
{ _id: 3, description: "Many spaces before line" },
{ _id: 4, description: "Multiple\nline descriptions" },
{ _id: 5, description: "anchors, links and hyperlinks" },
{ _id: 6, description: "métier work vocation" }
])
9 trong mẫu:

db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
4

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

1
db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
7
to check if the

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

04 field contains an email address with

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

05 and categorize the feedback as

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

06 or

db.createCollection( "myColl", { collation: { locale: "fr", strength: 1 } } )

07.

db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
5

Hoạt động trả về các tài liệu sau:

db.myColl.insertMany([
{ _id: 1, category: "café" },
{ _id: 2, category: "cafe" },
{ _id: 3, category: "cafE" }
])
6