Skip to content

Commit ce91bfd

Browse files
Merge pull request #9 from mongodb-developer/fix/quick-fix
Fix/quick fix
2 parents 357266b + a029288 commit ce91bfd

5 files changed

Lines changed: 17 additions & 8 deletions
File renamed without changes.

java/103_aggregation_pipeline_lookup.ipynb renamed to java/102_aggregation_pipeline_lookup.ipynb

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
"import static com.mongodb.client.model.Aggregates.project;\n",
5353
"import static com.mongodb.client.model.Aggregates.limit;\n",
5454
"\n",
55+
"import static com.mongodb.client.model.Projections.include;\n",
56+
"import static com.mongodb.client.model.Projections.excludeId;\n",
57+
"import static com.mongodb.client.model.Projections.fields;\n",
58+
"\n",
5559
"import org.bson.Document;\n",
5660
"\n",
5761
"// Configure SLF4J Simple Logger to suppress MongoDB driver logs in the notebook output.\n",
@@ -98,12 +102,16 @@
98102
"source": [
99103
"AggregateIterable<Document> result = authors.aggregate(\n",
100104
" List.of(\n",
101-
" lookup(\"books\", // collection with the book data to read into authors\n",
102-
" \"books\", // array in authors documents with the ids of all books written by an author\n",
103-
" \"_id\", // field in the books collection to link with\n",
104-
" \"booksWritten\" // name of a newly created field with all this info\n",
105-
" ),\n",
106-
" project(Projections.exclude(\"_id\")),\n",
105+
" lookup(\n",
106+
" \"books\", // collection with the book data to read into authors\n",
107+
" \"books\", // array in authors documents with the ids of all books written by an author\n",
108+
" \"_id\", // field in the books collection to link with\n",
109+
" \"booksWritten\" // name of a newly created field with all this info\n",
110+
" ),\n",
111+
" project(fields(\n",
112+
" include(\"name\", \"booksWritten.title\", \"booksWritten.pages\", \"booksWritten.year\"),\n",
113+
" excludeId()\n",
114+
" )),\n",
107115
" limit(20)\n",
108116
" )\n",
109117
");\n",
@@ -149,7 +157,8 @@
149157
"\n",
150158
"AggregateIterable<Document> result = books.aggregate(\n",
151159
" List.of(\n",
152-
" <REPLACE_WITH_LOOKUP_STAGE> \n",
160+
" <REPLACE_WITH_LOOKUP_STAGE>,\n",
161+
" <REPLACE_WITH_LIMIT_STAGE> \n",
153162
" )\n",
154163
");\n",
155164
"\n",

java/104_aggregation_pipeline_group_by.ipynb renamed to java/103_aggregation_pipeline_group_by.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
"### 2. Find the top 5 users with the highest number of reviews - use (Sort + Sum)\n",
157157
"Hint: use `sum` + `sort` to count and order the results, and don’t forget to use `limit` to keep the output easier to inspect.\n",
158158
"\n",
159-
"[Solution here](https://mongodb-developer.github.io/sql-to-query-api-lab/docs/aggregation/group#-2-find-users-with-the-most-number-of-reviews-hint-use-the-name-field-in-the-reviews-collection)"
159+
"[Solution here](https://mongodb-developer.github.io/sql-to-query-api-lab/docs/aggregation/group#-2-find-the-top-5-users-with-the-most-number-of-reviews-hint-use-the-name-field-in-the-reviews-collection)"
160160
]
161161
},
162162
{
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)