-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
While exploring ways to retrieve or "$merge"/"$out" unique documents from a collection, I ran across the following "oddity".
mongoplayground mgodatagen configuration:
[
{
"collection": "collection",
"count": 100,
"content": {
"key1": {
"type": "int",
"minInt": 0,
"maxInt": 1
},
"key2": {
"type": "int",
"minInt": 0,
"maxInt": 1
}
}
}
]Query:
db.collection.aggregate([
{
"$unset": "_id"
},
{
"$group": {
"_id": "$$ROOT"
}
},
{
"$replaceWith": "$_id"
}
])Result: (should just be 4 docs, but it's not - there are repeats)
[
{
"key1": 1,
"key2": 1
},
{
"key1": 1,
"key2": 0
},
{
"key1": 1,
"key2": 0
},
{
"key1": 1,
"key2": 1
},
{
"key1": 0,
"key2": 0
},
{
"key1": 0,
"key2": 1
},
{
"key1": 0,
"key2": 0
},
{
"key1": 0,
"key2": 1
}
]Using the same collection and query on MongoDB Atlas, the expected output of just 4 documents was produced.
The MongoDB Atlas Cluster I used is at version 5.0.13 so maybe it's a MongoDB server regression?
Metadata
Metadata
Assignees
Labels
No labels