You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Introduction to MongoDB in Python/4. Aggregation Pipelines: Let the Server Do It For You.md
+23Lines changed: 23 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -230,3 +230,26 @@ pipeline = [
230
230
print(list(db.laureates.aggregate(pipeline)))
231
231
```
232
232
[{'awardedElsewhere': 478}]
233
+
234
+
## 🦍 Refinement: filter out "unaffiliated" people
235
+
-[x] Construct a stage added_stage that filters for laureate "prizes.affiliations.country" values that are non-empty, that is, are $in a list of the distinct values that the field takes in the collection.
236
+
-[x] Insert this stage into the pipeline so that it filters out single prizes (not arrays) and precedes any test for membership in an array of countries. Recall that the first parameter to <list>.insert is the (zero-based) index for insertion.
0 commit comments