I am trying to run $facet aggregation in order to get documents according to $match with $skip and the count of matching documents.
I found there is no $facet aggregation in ReactiveMongo. How can I do this in my playframework 2.7 app?
Any aggregation stage can be written using PipelineOperator (if no convenient function provided).
Related
With MongoDb 4.2, we have new aggregation stage $set. As per docs,
$set stage is an alias for $addFields (from mongoDb 3.4)
But nothing mentioned why the need to have two stages with same functionality.
Can someone help to understand this ? (possibly since versions < 4.0 will be depricated soon )
MongoDB 4.2 introduced update commands that can accept an aggregation pipeline.
$set has long been an update operator, which does the same thing in updates as the $addFields stage does in aggregation.
Permitting either name to be used in an aggregation pipeline eases the adoption of the new update command.
based on docs in mongoDB Change Stream Docs i can use only these operations for getting output of change stream:
$addFields
$match
$project
$replaceRoot
$replaceWith (Available starting in MongoDB 4.2)
$redact
$set (Available starting in MongoDB 4.2)
$unset (Available starting in MongoDB 4.2)
but I want to use $lookup op :(
Do you have any idea to achieve this?
The allowed operations are transformations on the change stream-produced documents. You are asking about joining other collections.
If you want to join other collections, you need to issue those queries separately from the change stream.
I am using mongodb 3.4.
In my application, I have an aggregation operation with a $limit stage.
Now I want to know how I can get all records from the pipeline, ignoring the $limit. Removing $limit is not feasible because I need all records only in a specific scenario.
In the mongodb find() operation, I know I can bypass the cursor.limit() operation by passing 0 as the limit, and I'm looking for something similar for aggregation $limit.
The MongoDB documentation says about map-reduce:
For most aggregation operations, the Aggregation Pipeline provides better performance and more coherent interface. However, map-reduce operations provide some flexibility that is not presently available in the aggregation pipeline.
Does it mean that there are some aggregation operations that cannot be performed in the usual MongoDB aggregation framework but are possible using map-reduce?
In particular I'm looking for an example of map-reduce that cannot be implemented in the MongoDB aggregation framework
Thanks!
An example of "flexibility". Basically, if you have any logic, that does not fit into standard aggregation operators, map-reduce is the only option to do it serverside.
If you created a textIndex on mongodb 2.6 when you find or use the pipeline aggregate framework you can get the textScore given a query with the projection:
{'$meta': "textScore"}
This allows to operate with the textScore in further operations.
Is it possible to acces such value during a map-reduce operation?