You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -243,6 +243,40 @@ The search returns the following documents:
243
243
To learn more about the ``exists`` operator, see the :atlas:`exists </atlas-search/exists>`
244
244
Atlas guide.
245
245
246
+
Facet
247
+
~~~~~
248
+
249
+
Use the ``Facet()`` method to group results by values or ranges in the specified faceted fields
250
+
and return the count for each of those groups.
251
+
252
+
You can use the ``Facet()`` method with both the ``$search`` and ``$searchMeta`` stages. MongoDB recommends using
253
+
facet with the ``$searchMeta`` stage to retrieve metadata results only for the query.
254
+
To retrieve metadata results and query results using the ``$search`` stage, you must use the
255
+
``$$SEARCH_META`` aggregation variable. To learn more about this variable, see the :atlas:`SEARCH_META Aggregation Variable </atlas-search/facet/#std-label-fts-facet-aggregation-variable>` Atlas guide.
256
+
257
+
The following limitations apply:
258
+
259
+
- You can run facet queries on a single field only. You can't run facet queries on groups of fields.
260
+
- You can run facet queries over sharded collections on clusters running MongoDB v6.0 only.
261
+
262
+
The following example searches the ``guitars`` collection for any documents in
263
+
which the value of the ``in_stock`` field is ``true``. The query uses the ``Facet()`` method to process the input documents, with a maximum number of ``100`` facet categories to return in the results. The query returns the total count of documents in which the value of ``in_stock`` is ``true``.
To learn more about the ``facet`` collector, see the :atlas:`facet </atlas-search/facet>`
278
+
Atlas guide.
279
+
246
280
GeoShape
247
281
~~~~~~~~
248
282
@@ -703,6 +737,60 @@ The search returns the following document:
703
737
To learn more about the ``wildcard`` operator, see the :atlas:`wildcard </atlas-search/wildcard>`
704
738
Atlas guide.
705
739
740
+
Search Multiple Fields
741
+
----------------------
742
+
743
+
The ``path`` parameter is used by the Atlas Search
744
+
:atlas:`operators </atlas-search/query-syntax>` to specify the field or fields
745
+
to be searched. To learn more about what the ``path`` parameter may contain, see the :atlas:`Construct a Query Path </atlas-search/path-construction>` guide.
746
+
747
+
.. note::
748
+
749
+
Not all operators can use all the different types of paths. See the
750
+
documentation for each individual operator for details on what types
751
+
of path it supports.
752
+
753
+
To search multiple indexed fields, use the ``Multi()`` method and pass in your fields. Documents which match on any of the specified fields are included in the result set.
754
+
755
+
The following example searches for the string ``classic`` in either the ``make`` or the ``description`` field.
{ "_id" : 1, "make" : "Fender", "description" : "Classic guitars known for their versatility.", "establishedYear" : 1946, "in_stock" : true, "rating" : 9}
768
+
{ "_id" : 2, "make" : "Gibson", "description" : "Classic guitars known for their rich, full tones.", "establishedYear" : 1902, "in_stock" : true, "rating" : 8}
769
+
770
+
Score Documents
771
+
---------------
772
+
773
+
Every document returned by an Atlas Search query is assigned a score based on relevance, and the documents included in a result set are returned in order from highest score to lowest. To learn more about how scores are assigned, see the :atlas:`score </atlas-search/scoring>` Atlas guide.
774
+
775
+
The score assigned to a returned document is part of the document's metadata. You can include each returned document's score along with the result set by using a ``$project`` stage in your aggregation pipeline.
776
+
777
+
The following example searches the ``guitars`` collection for documents in which the value of the ``make`` field contains exactly six letters and uses a ``$project`` stage to add a field named ``score`` to the returned documents.
0 commit comments