Skip to content

Commit 091eec4

Browse files
committed
WIP
1 parent fdabb99 commit 091eec4

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

source/aggregation.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ by using Search operators.
230230
:language: console
231231
:visible: false
232232

233-
Document{{_id=573a1397f29313caabce86db, genres=[Drama, Sport], cast=[Sylvester Stallone, Talia Shire, Burt Young, Carl Weathers], title=Rocky III, year=1982}}
234-
Document{{_id=573a1398f29313caabce9af0, genres=[Drama, Sport], cast=[Sylvester Stallone, Talia Shire, Burt Young, Carl Weathers], title=Rocky IV, year=1985}}
233+
Document{{_id=..., genres=[Comedy, Romance], title=Love at First Bite, year=1979}}
234+
Document{{_id=..., genres=[Comedy, Drama], title=Love Affair, year=1994}}
235235

236236
Additional Information
237237
----------------------
@@ -263,3 +263,6 @@ see the following API documentation:
263263

264264
- `aggregate() <{+driver-api+}/-mongo-collection/aggregate.html>`__
265265
- `AggregateIterable <{+driver-api+}/-aggregate-iterable/index.html>`__
266+
- `Aggregates <{+core-api+}/client/model/Aggregates>`__
267+
- `search() <{+core-api+}/client/model/Aggregates#search(com.mongodb.client.model.search.SearchOperator)>`__
268+
- `project() <{+core-api+}/client/model/Aggregates#project(org.bson.conversions.Bson)>`__

source/includes/aggregation/aggregation.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ fun main() {
5151
SearchOperator.compound()
5252
.filter(
5353
listOf(
54-
SearchOperator.text(fieldPath("genres"), "Drama"),
55-
SearchOperator.phrase(fieldPath("cast"), "sylvester stallone"),
56-
SearchOperator.numberRange(fieldPath("year")).gtLt(1980, 1989),
57-
SearchOperator.wildcard(fieldPath("title"), "Rocky *")
54+
SearchOperator.`in`(fieldPath("genres"), listOf("Comedy")),
55+
SearchOperator.phrase(fieldPath("fullplot"), "new york"),
56+
SearchOperator.numberRange(fieldPath("year")).gtLt(1950, 2000),
57+
SearchOperator.wildcard(fieldPath("title"), "Love *")
5858
)
5959
)
6060
)
6161

6262
val projectStage = Aggregates.project(
63-
Projections.include("title", "year", "genres", "cast"))
63+
Projections.include("title", "year", "genres"))
6464

65-
val aggregatePipelineStages = listOf(searchStage, projectStage)
66-
val results = collection.aggregate(aggregatePipelineStages)
65+
val pipeline = listOf(searchStage, projectStage)
66+
val results = collection.aggregate(pipeline)
6767

6868
results.forEach { result -> println(result) }
6969
// end-atlas-searchoperator-helpers

0 commit comments

Comments
 (0)