Skip to content

docsp-33327 - update window api #502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions source/fundamentals/builders/aggregates.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
Aggregates Builders
===================

.. facet::
:name: genre
:values: reference

.. meta::
:keywords: code examples

.. contents:: On this page
:local:
:backlinks: none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ public static void main(String[] args) {
page.bucketAutoOptionsStage();
page.facetStage();
page.vectorSearchPipeline();
// Fix required: https://jira.mongodb.org/browse/DOCSP-33327
// page.setWindowFieldsStage();
page.setWindowFieldsStage();
page.aggregationExample();
}

Expand All @@ -95,16 +94,14 @@ private void aggregationExample() {
// end aggregationSample
}

/* Fix required: https://jira.mongodb.org/browse/DOCSP-33327
private void setWindowFieldsStage() {
// begin setWindowFields
Window pastMonth = Windows.timeRange(-1, MongoTimeUnit.MONTH, Windows.Bound.CURRENT);
setWindowFields("$localityId", Sorts.ascending("measurementDateTime"),
WindowedComputations.sum("monthlyRainfall", "$rainfall", pastMonth),
WindowedComputations.avg("monthlyAvgTemp", "$temperature", pastMonth));
WindowOutputFields.sum("monthlyRainfall", "$rainfall", pastMonth),
WindowOutputFields.avg("monthlyAvgTemp", "$temperature", pastMonth));
// end setWindowFields
}
*/

private void facetStage() {
// begin facet
Expand Down Expand Up @@ -258,10 +255,11 @@ private void advancedLookupStage() {
Bson innerJoinLookup = lookup("warehouses", variables, pipeline, "stockdata");
// end advanced lookup
// Missing advancedLookup assignment
// MongoCursor<Document> cursor = collection.aggregate(asList(advancedLookup)).cursor();
// cursor.forEachRemaining(doc -> System.out.println(doc.toJson()));
// database = mongoClient.getDatabase("sample_mflix");
// collection = database.getCollection("movies");
// MongoCursor<Document> cursor =
// collection.aggregate(asList(advancedLookup)).cursor();
// cursor.forEachRemaining(doc -> System.out.println(doc.toJson()));
// database = mongoClient.getDatabase("sample_mflix");
// collection = database.getCollection("movies");
}

private void basicLookupStage() {
Expand Down Expand Up @@ -332,7 +330,7 @@ private void vectorSearchPipeline() {
limit,
options),
project(
metaVectorSearchScore("vectorSearchScore")));
metaVectorSearchScore("vectorSearchScore")));
// end vectorSearch

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


private void documentsStage() {
// begin documents
documents(asList(
Expand Down