Skip to content

Commit d62f3e8

Browse files
committed
docsp-33327 - update window api (#502)
(cherry picked from commit 19a6c21)
1 parent da5d8d6 commit d62f3e8

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

source/fundamentals/builders/aggregates.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
Aggregates Builders
33
===================
44

5+
.. facet::
6+
:name: genre
7+
:values: reference
8+
9+
.. meta::
10+
:keywords: code examples
11+
512
.. contents:: On this page
613
:local:
714
:backlinks: none

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ public static void main(String[] args) {
8282
page.bucketAutoOptionsStage();
8383
page.facetStage();
8484
page.vectorSearchPipeline();
85-
// Fix required: https://jira.mongodb.org/browse/DOCSP-33327
86-
// page.setWindowFieldsStage();
85+
page.setWindowFieldsStage();
8786
page.aggregationExample();
8887
}
8988

@@ -95,16 +94,14 @@ private void aggregationExample() {
9594
// end aggregationSample
9695
}
9796

98-
/* Fix required: https://jira.mongodb.org/browse/DOCSP-33327
9997
private void setWindowFieldsStage() {
10098
// begin setWindowFields
10199
Window pastMonth = Windows.timeRange(-1, MongoTimeUnit.MONTH, Windows.Bound.CURRENT);
102100
setWindowFields("$localityId", Sorts.ascending("measurementDateTime"),
103-
WindowedComputations.sum("monthlyRainfall", "$rainfall", pastMonth),
104-
WindowedComputations.avg("monthlyAvgTemp", "$temperature", pastMonth));
101+
WindowOutputFields.sum("monthlyRainfall", "$rainfall", pastMonth),
102+
WindowOutputFields.avg("monthlyAvgTemp", "$temperature", pastMonth));
105103
// end setWindowFields
106104
}
107-
*/
108105

109106
private void facetStage() {
110107
// begin facet
@@ -258,10 +255,11 @@ private void advancedLookupStage() {
258255
Bson innerJoinLookup = lookup("warehouses", variables, pipeline, "stockdata");
259256
// end advanced lookup
260257
// Missing advancedLookup assignment
261-
// MongoCursor<Document> cursor = collection.aggregate(asList(advancedLookup)).cursor();
262-
// cursor.forEachRemaining(doc -> System.out.println(doc.toJson()));
263-
// database = mongoClient.getDatabase("sample_mflix");
264-
// collection = database.getCollection("movies");
258+
// MongoCursor<Document> cursor =
259+
// collection.aggregate(asList(advancedLookup)).cursor();
260+
// cursor.forEachRemaining(doc -> System.out.println(doc.toJson()));
261+
// database = mongoClient.getDatabase("sample_mflix");
262+
// collection = database.getCollection("movies");
265263
}
266264

267265
private void basicLookupStage() {
@@ -332,7 +330,7 @@ private void vectorSearchPipeline() {
332330
limit,
333331
options),
334332
project(
335-
metaVectorSearchScore("vectorSearchScore")));
333+
metaVectorSearchScore("vectorSearchScore")));
336334
// end vectorSearch
337335

338336
// begin vectorSearch-output
@@ -345,7 +343,6 @@ private void vectorSearchPipeline() {
345343
// Example output: "vectorSearch score: 0.887437105178833"
346344
}
347345

348-
349346
private void documentsStage() {
350347
// begin documents
351348
documents(asList(

0 commit comments

Comments
 (0)