-
Type: Question
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.6.22
-
Component/s: Querying
-
None
Hello,
I have an issue when querying a collection using this criteria :
{deleted_at: null, event_campaign_optin: true, event_id: ObjectId('5ea92da4a5522a080614d29f'), status: "registered", "label_ids": [ObjectId('6048a3c4b3d10c003c14b22e')]}=> It returns only one Object (instead of 5)
So I tried to add a filter on the ids of expected objects :
_id: {"$in": [ObjectId('60377e2172fcdc005b32e9ff'), ObjectId('5efdaeafa62e5400233657a0'), ObjectId('5efca695f820c7144e46ffda'), ObjectId('5ee0cebdb28593001c8bfaf2'), ObjectId('5ed65cd396f090255d089b77')]}
The complete query :
{deleted_at: null, event_campaign_optin: true, event_id: ObjectId('5ea92da4a5522a080614d29f'), status: "registered", "label_ids": [ObjectId('6048a3c4b3d10c003c14b22e')], _id: {"$in": [ObjectId('60377e2172fcdc005b32e9ff'), ObjectId('5efdaeafa62e5400233657a0'), ObjectId('5efca695f820c7144e46ffda'), ObjectId('5ee0cebdb28593001c8bfaf2'), ObjectId('5ed65cd396f090255d089b77')]}}
=> This one returns 5 objects
I do not understand how adding a AND filter on 5 ids could return more results ...
I executed this requests on the Atlas interface, same issue form mongoid ODM form the ruby console.
Any idea of what happen ? I have no clue.
I thought that the index used for the request could change the result, one request using a sparse index maybe ... so I forced the index to use with :
.extras(hint: {deleted_at: 1, event_id: 1, created_at: -1})
(from the ruby console this time, not atlas)
And still the same results.
Any clue is welcome. Thanks for your help.