The Atlas Search compound operator combines search operators in one $search query. Use it when a result must satisfy several search criteria rather than just one. section 11.5.1
Require three matches in an inspections search
In mongosh, run db.inspections.aggregate([{ $search: { index: "MongoDB-in-Action", compound: { must: [{ text: { query: "food", path: "business_name" } }, { text: { query: "PASS", path: "result" } }, { text: { query: "127", path: "sector" } }] } } }, { $set: { score: { $meta: "searchScore" } } }]). Each must clause must match: the business name contains “food,” the result contains “PASS,” and the sector contains “127.” The added score indicates how well a returned document matches the search criteria. section 11.5.1
Run the query against an Atlas Search index. To try compound searches without changing a live collection, use the Atlas Search Playground’s Customer Lookup environment; its setup is not persistent, though a shared snapshot URL remains valid for 30 days. section 11.5.1 section 11.7
