'Batch update with aggregation in MongoDB
I have a list of pipeline operations and would like to use the result to update on the collection by _id.
Right now I have something like this in java:
Cursor cursor = getCollection().aggregate(
Arrays.asList(
pipeline1,
pipline2,
...
), AggregationOptions.builder().allowDiskUse(true).batchSize(1000).build()
);
how would I make it do the update as well without iterating through the cursor as it would co through my java service and update one by one. How would I something like:
[collection].updateMany(
{},
[
pipeline1,
pipeline2
]
)
instead? The aggregation result is very large (hundreds of thousands) so updating one by one isn't an option.
If there's some better way to do this please share too.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
