Hướng dẫn $or in match mongodb - $ hoặc trong mongodb phù hợp
Tài liệu về nhà → Hướng dẫn sử dụng MongoDB → MongoDB Manual $match Filters Các tài liệu chỉ truyền các tài liệu phù hợp với (các) điều kiện được chỉ định cho giai đoạn đường ống tiếp theo.Filters the documents to pass only the documents that match the specified condition(s) to the next pipeline stage. Giai đoạn
0 query expression to include aggregation expression in
$match
Các ví dụ sử dụng một bộ sưu tập có tên 6 với các tài liệu sau:
Hoạt động sau sử dụng
9 bằng 0 và tổng hợp trả về như sau:$match selects the documents where the 9 field equals 0, and the aggregation returns the following:
Ví dụ sau chọn các tài liệu để xử lý bằng toán tử đường ống 2 để tính toán số lượng tài liệu:$match pipeline operator and then pipes the results to the 2 pipeline operator to compute a count of the documents:
Trong đường ống tổng hợp, 4 lớn hơn 5 và nhỏ hơn 6 hoặc 7 lớn hơn hoặc bằng 8. Các tài liệu này sau đó được đưa đến 2 để thực hiện đếm. Tổng hợp trả về những điều sau:$match selects the documents where either the 4 is greater than 5 and less than 6 or the 7 is greater than or equal to 8. These documents are then piped to the 2 to perform a
count. The aggregation returns the following:
Tham khảo các trang sau để biết thêm thông tin và sử dụng các trường hợp về tổng hợp. Đối với các truy vấn 0 của bạn đối với dữ liệu trên cụm Atlas của bạn, bạn có thể sử dụng tùy chọn Toán tử Atlas SearchCompound 1 để khớp hoặc lọc tài liệu. Chạy $match sau 0 ít hoạt động hơn so với chạy 0 với tùy chọn toán tử tổng hợp 1. Để tìm hiểu thêm về tùy chọn 1, xem Hợp chất. 0 queries against data on your
Atlas cluster, you can use the Atlas Search compound operator 1 option to match or filter documents. Running
$match after 0 is less performant than running
0 with the compound operator 1 option. To learn more about the 1 option, see compound.
|