@@ -25,12 +25,20 @@ In this guide, you can learn how to use the **Atlas Search** feature on a collec
25
25
Atlas Search enables you to perform full-text searches on collections hosted on MongoDB
26
26
Atlas. Atlas Search indexes specify the behavior of the search and which fields to index.
27
27
28
+ Sample Data
29
+ ~~~~~~~~~~~
30
+
31
+ The example in this guide uses the ``movies`` collection in the ``sample_mflix``
32
+ database from the :atlas:`Atlas sample datasets </sample-data>`. To learn how to
33
+ create a free MongoDB Atlas cluster and load the sample datasets, see the
34
+ :atlas:`Get Started with Atlas </getting-started>` guide.
35
+
28
36
Run an Atlas Search Query
29
37
-------------------------
30
38
31
39
This section shows how to create an aggregation pipeline to run an
32
- Atlas Search on a collection. You can use ``Aggregates.search`` builder to
33
- create a ``$search`` pipeline stage and specify your search. Then, call
40
+ Atlas Search on a collection. You can use the ``Aggregates.search() `` builder
41
+ method to create a ``$search`` pipeline stage and specify your search. Then, call
34
42
the ``aggregate()`` method and pass your pipeline as a parameter.
35
43
36
44
.. tip::
@@ -42,23 +50,16 @@ Before running an Atlas Search query, you must create an Atlas Search index
42
50
on your collection. To learn how to programmatically create an Atlas Search
43
51
index, see the :ref:`java-search-indexes` section in the Indexes guide.
44
52
45
- Sample Data
46
- ~~~~~~~~~~~
47
-
48
- The example in this section uses the ``movies`` collection in the ``sample_mflix``
49
- database from the :atlas:`Atlas sample datasets </sample-data>`. To learn how to
50
- create a free MongoDB Atlas cluster and load the sample datasets, see the
51
- :atlas:`Get Started with Atlas </getting-started>` guide.
52
-
53
53
Atlas Search Example
54
54
~~~~~~~~~~~~~~~~~~~~
55
55
56
56
This example performs an Atlas Search query by calling the
57
- ``aggregate()`` method and passing the following pipeline stages:
57
+ ``aggregate()`` method and passing the following pipeline stage
58
+ builders:
58
59
59
- - ``Aggregates.search``: Specifies a search query for documents in which
60
+ - ``Aggregates.search() ``: Specifies a search query for documents in which
60
61
the ``title`` field contains the word ``"Alabama"``
61
- - ``Aggregates.project``: Projects the ``title`` field of each matching document
62
+ - ``Aggregates.project() ``: Projects the ``title`` field of each matching document
62
63
63
64
.. io-code-block::
64
65
:copyable:
@@ -92,9 +93,9 @@ in the Atlas documentation.
92
93
API Documentation
93
94
~~~~~~~~~~~~~~~~~
94
95
95
- To learn more about the methods and pipeline stages mentioned in this guide, see
96
+ To learn more about the methods mentioned in this guide, see
96
97
the following API documentation:
97
98
98
99
- `MongoCollection.aggregate() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#aggregate(java.util.List)>`__
99
- - `Aggregates.search <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/Aggregates.html#search(com.mongodb.client.model.search.SearchCollector)>`__
100
- - `Aggregates.project <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/Aggregates.html#project(org.bson.conversions.Bson)>`__
100
+ - `Aggregates.search() <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/Aggregates.html#search(com.mongodb.client.model.search.SearchCollector)>`__
101
+ - `Aggregates.project() <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/Aggregates.html#project(org.bson.conversions.Bson)>`__
0 commit comments