Skip to content

Commit e71942e

Browse files
committed
WIP
1 parent 1b89126 commit e71942e

File tree

4 files changed

+34
-41
lines changed

4 files changed

+34
-41
lines changed

source/atlas-search.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,15 @@ Learn more about this helper from the
123123

124124
.. _java-atlas-search-helpers:
125125

126-
Building a Pipeline Search Stage
127-
--------------------------------
126+
Create Pipeline Search Stages
127+
-----------------------------
128128

129129
.. sharedinclude:: dbx/jvm/atlas-search-operator-helpers.rst
130130

131+
.. replacement:: as-idx-link
132+
133+
the :ref:`java-search-indexes` section of the Indexes guide
134+
131135
.. replacement:: atlas-query-operators-example
132136

133137
.. io-code-block::
@@ -141,13 +145,9 @@ Building a Pipeline Search Stage
141145
.. output::
142146
:language: console
143147
:visible: false
144-
145-
Document{{_id=573a1397f29313caabce86db, genres=[Drama, Sport], cast=[Sylvester Stallone, Talia Shire, Burt Young, Carl Weathers], title=Rocky III, year=1982}}
146-
Document{{_id=573a1398f29313caabce9af0, genres=[Drama, Sport], cast=[Sylvester Stallone, Talia Shire, Burt Young, Carl Weathers], title=Rocky IV, year=1985}}
147-
148-
.. replacement:: searchoperator-interface-api-docs
149-
150-
the `SearchOperator Interface API documentation <{+core-api+}/client/model/search/SearchOperator.html>`__
148+
149+
{"_id": ..., "genres": ["Comedy", "Romance"], "title": "Love at First Bite", "year": 1979}
150+
{"_id": ..., "genres": ["Comedy", "Drama"], "title": "Love Affair", "year": 1994}
151151

152152
Additional Information
153153
----------------------
@@ -164,4 +164,4 @@ the following API documentation:
164164
- `MongoCollection.aggregate() <{+driver-api+}/MongoCollection.html#aggregate(java.util.List)>`__
165165
- `Aggregates.search() <{+core-api+}/client/model/Aggregates.html#search(com.mongodb.client.model.search.SearchCollector)>`__
166166
- `Aggregates.project() <{+core-api+}/client/model/Aggregates.html#project(org.bson.conversions.Bson)>`__
167-
- `SearchOperator <{+core-api+}/client/model/search/SearchOperator.html>`__
167+
- `SearchOperator <{+core-api+}/client/model/search/SearchOperator.html>`__

source/crud/read-write-config.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,10 @@ API Documentation
333333
To learn more about any of the methods or types discussed in this
334334
guide, see the following API documentation:
335335

336-
- `MongoClient <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoClient.html>`__
337-
- `MongoClientSettings <{+api+}/apidocs/mongodb-driver-core/com/mongodb/MongoClientSettings.html>`__
338-
- `TransactionOptions <{+api+}/apidocs/mongodb-driver-core/com/mongodb/TransactionOptions.html>`_
339-
- `startTransaction() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/ClientSession.html#startTransaction()>`_
340-
- `MongoDatabase <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoDatabase.html>`__
341-
- `MongoCollection <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html>`__
342-
- `TagSet <{+api+}/apidocs/mongodb-driver-core/com/mongodb/TagSet.html>`_
336+
- `MongoClient <{+driver-api+}/MongoClient.html>`__
337+
- `MongoClientSettings <{+core-api+}/MongoClientSettings.html>`__
338+
- `TransactionOptions <{+core-api+}/TransactionOptions.html>`_
339+
- `startTransaction() <{+driver-api+}/ClientSession.html#startTransaction()>`_
340+
- `MongoDatabase <{+driver-api+}/MongoDatabase.html>`__
341+
- `MongoCollection <{+driver-api+}/MongoCollection.html>`__
342+
- `TagSet <{+core-api+}/TagSet.html>`_

source/includes/fundamentals/code-snippets/builders/AggregateSearchBuilderExample.java

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,33 +60,25 @@ private static void runAtlasTextSearch(MongoCollection<Document> collection) {
6060
*/
6161
private static void runAtlasSearchWithSearchHelperMethods(MongoCollection<Document> collection) {
6262
// begin atlasHelperMethods
63-
Bson searchStageFilters = Aggregates.search(
63+
List<Bson> pipeline = new ArrayList<>();
64+
65+
pipeline.add(Aggregates.search(
6466
SearchOperator.compound()
6567
.filter(
66-
List.of(
67-
SearchOperator.text(fieldPath("genres"), "Drama"),
68-
SearchOperator.phrase(fieldPath("cast"), "sylvester stallone"),
69-
SearchOperator.numberRange(fieldPath("year")).gtLt(1980, 1989),
70-
SearchOperator.wildcard(fieldPath("title"),"Rocky *")
71-
)));
72-
73-
Bson projection = Aggregates.project(Projections.fields(
74-
Projections.include("title", "year", "genres", "cast")
68+
Arrays.asList(
69+
SearchOperator.in(fieldPath("genres"), Arrays.asList("Comedy")),
70+
SearchOperator.phrase(fieldPath("fullplot"), "new york"),
71+
SearchOperator.numberRange(fieldPath("year")).gtLt(1950, 2000),
72+
SearchOperator.wildcard(fieldPath("title"), "Love *")
73+
))));
74+
75+
pipeline.add(Aggregates.project(
76+
Projections.include("title", "year", "genres")
7577
));
7678

77-
List<Bson> aggregateStages = List.of(searchStageFilters, projection);
78-
collection.aggregate(aggregateStages).forEach(System.out::println);
79-
79+
AggregateIterable<Document> results = collection.aggregate(pipeline);
80+
results.forEach(doc -> System.out.println(doc.toJson()));
8081
// end atlasHelperMethods
81-
82-
// To condense result data, add this projection into the pipeline
83-
// Bson projection = Aggregates.project(Projections.fields(Projections.include("title", "released")));
84-
85-
List<Bson> aggregateStages = List.of(searchStageFilters);
86-
System.out.println("aggregateStages: " + aggregateStages);
87-
88-
System.out.println("explain:\n" + collection.aggregate(aggregateStages).explain());
89-
collection.aggregate(aggregateStages).forEach(result -> System.out.println(result));
9082
}
9183

9284
/*
@@ -137,8 +129,9 @@ public static void main(String[] args) {
137129
// Uncomment the methods that correspond to what you're testing
138130
// runMatch(collection);
139131
// runAtlasTextSearch(collection);
140-
runAtlasSearch(collection);
132+
// runAtlasSearch(collection);
141133
// runAtlasTextSearchMeta(collection);
134+
// runAtlasSearchWithSearchHelperMethods(collection);
142135
}
143136
}
144137
}

source/references/whats-new.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ and features:
5858

5959
.. replacement:: atlas-query-operators
6060

61-
the :ref:`java-atlas-search-helpers` section of the Atlas Search page.
61+
the :ref:`java-atlas-search-helpers` section of the Atlas Search guide
6262

6363
.. _java-version-5.3:
6464

0 commit comments

Comments
 (0)