Skip to content

Commit 223840c

Browse files
committed
RR review
1 parent 0ea55ce commit 223840c

File tree

2 files changed

+58
-34
lines changed

2 files changed

+58
-34
lines changed

source/aggregation.txt

Lines changed: 57 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -80,39 +80,6 @@ The following limitations apply when using aggregation operations:
8080
</reference/operator/aggregation/graphLookup/>` stage has a strict
8181
memory limit of 100 megabytes and ignores the ``allowDiskUse`` option.
8282

83-
.. _kotlin-sync-atlas-search-stage:
84-
85-
Pipelines Stages for Atlas Search
86-
---------------------------------
87-
88-
:atlas:`Atlas Search </atlas-search>` queries take the form of an aggregation pipeline stage. Atlas
89-
Search provides ``$search`` and ``$searchMeta`` stages, both of which must be the first
90-
stage in any query pipeline. For more information about Atlas pipeline stages,
91-
see the :atlas:`Choose the Aggregation Pipeline Stage
92-
</atlas-search/query-syntax/>` page in the Atlas
93-
manual.
94-
95-
.. sharedinclude:: dbx/jvm/atlas-search-operator-helpers.rst
96-
97-
.. replacement:: atlas-query-operators-example
98-
99-
.. code-block:: kotlin
100-
101-
val searchStage: Bson = Aggregates.search(
102-
SearchOperator.compound()
103-
.filter(
104-
listOf(
105-
SearchOperator.text(fieldPath("genres"), "Drama"),
106-
SearchOperator.phrase(fieldPath("cast"), "sylvester stallone"),
107-
SearchOperator.numberRange(fieldPath("year")).gtLt(1980, 1989),
108-
SearchOperator.wildcard(fieldPath("title"), "Rocky *")
109-
)
110-
)
111-
)
112-
113-
.. replacement:: searchoperator-interface-api-docs
114-
115-
the `SearchOperator Interface API documentation <{+core-api+}/client/model/search/SearchOperator.html>`__
11683

11784
Aggregation Example
11885
-------------------
@@ -222,6 +189,63 @@ and adds the ``$explain`` stage to output the operation details:
222189
...
223190
}
224191

192+
.. _kotlin-sync-atlas-search-stage:
193+
194+
Atlas Search
195+
------------
196+
197+
You can perform an :atlas:`Atlas Search </atlas-search>` query by creating an aggregation pipeline
198+
that contains one of the following pipeline stages:
199+
200+
- ``$search``
201+
- ``$searchMeta``
202+
203+
For more information about Atlas pipeline stages, see the :atlas:`Choose the
204+
Aggregation Pipeline Stage </atlas-search/query-syntax/>` page in the Atlas
205+
documentation.
206+
207+
Create a Pipeline Search Stage
208+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
209+
210+
You can build a Atlas Search pipeline stage using search operators.
211+
212+
.. sharedinclude:: dbx/jvm/atlas-search-operator-helpers.rst
213+
214+
.. replacement:: atlas-query-operators-example
215+
216+
.. io-code-block::
217+
218+
.. input::
219+
:language: kotlin
220+
221+
val searchStage: Bson = Aggregates.search(
222+
SearchOperator.compound()
223+
.filter(
224+
listOf(
225+
SearchOperator.text(fieldPath("genres"), "Drama"),
226+
SearchOperator.phrase(fieldPath("cast"), "sylvester stallone"),
227+
SearchOperator.numberRange(fieldPath("year")).gtLt(1980, 1989),
228+
SearchOperator.wildcard(fieldPath("title"), "Rocky *")
229+
)
230+
)
231+
)
232+
233+
val aggregatePipelineStages: List<Bson> = listOf(searchStage, Aggregates.project(projection))
234+
val results = collection.aggregate<Document>(aggregatePipelineStages)
235+
236+
results.forEach { result -> println(result) }
237+
238+
.. output::
239+
:language: console
240+
:visible: false
241+
242+
Document{{_id=573a1397f29313caabce86db, genres=[Drama, Sport], cast=[Sylvester Stallone, Talia Shire, Burt Young, Carl Weathers], title=Rocky III, year=1982}}
243+
Document{{_id=573a1398f29313caabce9af0, genres=[Drama, Sport], cast=[Sylvester Stallone, Talia Shire, Burt Young, Carl Weathers], title=Rocky IV, year=1985}}
244+
245+
.. replacement:: searchoperator-interface-api-docs
246+
247+
the `SearchOperator Interface API documentation <{+core-api+}/client/model/search/SearchOperator.html>`__
248+
225249
Additional Information
226250
----------------------
227251

source/whats-new.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ and features:
4545
.. replacement:: atlas-query-operators
4646

4747
the :ref:`Pipelines Stages for Atlas Search
48-
<kotlin-sync-atlas-search-stage>` section
48+
<kotlin-sync-atlas-search-stage>` section of the Aggregation guide
4949

5050
.. _kotlin-sync-version-5.3:
5151

0 commit comments

Comments
 (0)