@@ -80,39 +80,6 @@ The following limitations apply when using aggregation operations:
80
80
</reference/operator/aggregation/graphLookup/>` stage has a strict
81
81
memory limit of 100 megabytes and ignores the ``allowDiskUse`` option.
82
82
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>`__
116
83
117
84
Aggregation Example
118
85
-------------------
@@ -222,6 +189,63 @@ and adds the ``$explain`` stage to output the operation details:
222
189
...
223
190
}
224
191
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
+
225
249
Additional Information
226
250
----------------------
227
251
0 commit comments