@@ -22,18 +22,18 @@ Overview
2222 Retrieve documents in MongoDB with a query on multiple fields.
2323
2424In this guide, you will learn how to use multiple search operators in
25- a compound query using the aggregation pipeline.
25+ a compound query by using the aggregation pipeline.
2626
27- .. time:: 15
27+ .. time:: 5
2828
2929What You'll Need
3030----------------
3131
3232- A MongoDB account. See :ref:`guides-create-atlas-account`.
3333- An Atlas cluster. See :ref:`guides-create-a-cluster`.
3434- Sample datasets :ref:`loaded into your cluster <guides-load-sample-data>`.
35- - A search index with default settings and dynamic indexing. See
36- :ref:`guides-search-dynamic`.
35+ - A search index with default settings and dynamic indexing.
36+ To create a default dynamic index, see :ref:`guides-search-dynamic`.
3737
3838Procedure
3939---------
@@ -43,79 +43,83 @@ Procedure
4343
4444 .. include:: /includes/navigate_to_collections.rst
4545
46- .. step:: In the right-hand pane, click ``sample_supplies``,
46+ .. step:: Click the ``sample_supplies`` database,
4747 then click the ``sales`` collection.
4848
49- .. step:: Run a query on your index using the Aggregation Pipeline .
49+ .. step:: Run a compound query on your index in the :guilabel:`Aggregations` tab .
5050
5151 .. procedure::
5252 :style: connected
5353
5454 .. step:: Click
5555 the :guilabel:`Aggregation` tab.
5656
57- .. step:: If you do not see a pipeline with an initial
58- stage window in the right pane, click
59- :guilabel:`Create New` and select :guilabel:`Pipeline`.
60-
57+ .. step:: Click :guilabel:`+ Add Stage` to begin creating
58+ your aggregation pipeline.
59+
6160 .. step:: In the stage window, click on the dropdown menu
62- labeled :guilabel:`Select... ` and select the
61+ labeled :guilabel:`Select` and select the
6362 :guilabel:`$search` stage.
6463
6564 .. step:: Replace the placeholder code with the following
66- ``compound`` operator:
65+ query.
6766
6867 .. code-block:: json
6968
7069 {
71- "compound": {
72- "filter": [{
73- "text": {
74- "query": "Online",
75- "path": "purchaseMethod"
76- }
77- }],
78- "should": [{
79- "text": {
80- "query": "notepad",
81- "path": "items"
82- }
83- }]
84- }
70+ "compound": {
71+ "filter": [{
72+ "text": {
73+ "query": "Online",
74+ "path": "purchaseMethod"
75+ }
76+ }],
77+ "should": [{
78+ "text": {
79+ "query": "notepad",
80+ "path": "items"
81+ }
82+ }]
83+ }
8584 }
8685
87- .. step:: Review the results of the compound search in the
88- right-hand pane. Your results should include the fields listed
89- in the following sample document.
86+ This query uses the ``compound`` operator with:
87+
88+ - The ``filter`` clause to return only documents
89+ with a ``purchaseMethod`` of ``Online``.
90+ - The ``should`` clause to return documents
91+ with an ``items`` field that contains ``notepad`` to have
92+ a higher score than those without.
93+
94+ .. step:: Review the results of the compound query.
9095
91- .. note::
92-
93- The fields will not always appear in the same order
94- for every returned document.
96+ In the right-hand pane, your results should include a list
97+ of documents that resemble the following sample document:
9598
9699 .. code-block:: json
97100 :copyable: false
98101
99102 items: Array
103+ 0: Object
104+ 1: Object
105+ 2: Object
106+ name: "notepad"
107+ ...
100108 storeLocation: "Denver"
101109 customer: Object
102110 couponUsed: false
103111 purchaseMethod: "Online"
104112 _id: ObjectID('5bd761dcae323e45a93cd06e')
105113 saleDate: 2013-11-22T18:49:45.212+00:00
106114
115+ .. note::
116+
117+ The fields don't always appear in the same order
118+ for every returned document.
119+
107120 You can expand ``Array`` and ``Object`` fields to view their
108121 contents by clicking on them.
109122
110- Due to the ``filter`` operator, only records with a
111- ``purchaseMethod`` value of ``Online`` appear.
112- Additionally, due to the ``should`` operator,
113- records with an ``items`` value of ``notepad`` score
114- higher than those without.
115-
116- You now have a ``$search`` aggregation stage with a compound
117- search definition.
118-
119123Summary
120124-------
121125
0 commit comments