...
BugZero found this defect 2653 days ago.
I have a document that should be returned by a query but isn't. Query: db.collection1.find({ location: { $near: { $geometry: { 'type': 'Point', 'coordinates': [ 2.350051, 48.8606455 ] }, $maxDistance: 100000 } }, $or: [ { booleanField3: false }, { booleanField3: { $exists: false } } ], stringField1: { $in: [ "bar" ] }, dateField1: ISODate("2017-07-05T00:00:00.000Z") }) Index (not sparse, not background): { "stringField1" : 1, "booleanField1" : 1, "booleanField2" : 1, "booleanField3" : 1, "booleanField4" : 1, "booleanField5" : 1, "booleanField6" : 1, "intField1" : -1, "stringField2" : 1, "dateField1" : 1, "dateField2" : 1, "intField2" : 1, "intField3" : 1, "intField4" : 1, "location" : "2dsphere" } Document: { _id: ObjectId("SOME_ID"), "location" : { "latitude" : 48.8620365, "longitude" : 2.3202073 }, booleanField1: true, booleanField2: true, booleanField3: false, booleanField5: true, stringField1: "bar", dateField1: ISODate("2017-07-05T00:00:00.000Z") /* Other fields */ } When I insert a document with a new ID and the same exact field values, it doesn't get returned either. When I insert a document with the same field values but a different value for the date field, the document is returned. I am available for a live demo.
thomas.schubert commented on Tue, 11 Jul 2017 16:15:24 +0000: Hi technical@tootsweet-app.com, The document in question specifies latitude before longitude within the embedded document. Therefore, the document is not being returned by the query. For additional information regarding this restriction, please review our documentation on legacy coordinate pairs. Correcting the order should resolve the issue. For example, { _id: ObjectId("SOME_ID"), "location" : { "longitude" : 2.3202073, "latitude" : 48.8620365 }, booleanField1: true, booleanField2: true, booleanField3: false, booleanField5: true, stringField1: "bar", dateField1: ISODate("2017-07-05T00:00:00.000Z") /* Other fields */ } Please note that SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag. A question like this would be best posted on the mongodb-users group. Kind regards, Thomas technical@tootsweet-app.com commented on Mon, 10 Jul 2017 15:58:29 +0000: Sorry for the horrible formatting, here it is: Query: db.collection1.find({ location: { $near: { $geometry: { 'type': 'Point', 'coordinates': [ 2.350051, 48.8606455 ] }, $maxDistance: 100000 } }, $or: [ { booleanField3: false }, { booleanField3: { $exists: false } } ], stringField1: { $in: [ "bar" ] }, dateField1: ISODate("2017-07-05T00:00:00.000Z") }) Index (not sparse, not background): { "stringField1" : 1, "booleanField1" : 1, "booleanField2" : 1, "booleanField3" : 1, "booleanField4" : 1, "booleanField5" : 1, "booleanField6" : 1, "intField1" : -1, "stringField2" : 1, "dateField1" : 1, "dateField2" : 1, "intField2" : 1, "intField3" : 1, "intField4" : 1, "location" : "2dsphere" } Document: { _id: ObjectId("SOME_ID"), "location" : { "latitude" : 48.8620365, "longitude" : 2.3202073 }, booleanField1: true, booleanField2: true, booleanField3: false, booleanField5: true, stringField1: "bar", dateField1: ISODate("2017-07-05T00:00:00.000Z") /* Other fields */ }