-
Type: Question
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.6.1
-
Component/s: Querying
-
None
I am running mongodb version 2.6.1. I have a sparse index on testField. This query:
db.testCollection.find({ testField: "123"})
uses my index. This query:
db.testCollection.find( {testField: { $exists: true } })
does this as well. But this query:
db.testCollection.find({ testField: {$ne: null } })
perform a full collection scan. According to the documentation: "If a sparse index results in an incomplete result set for queries and sort operations, MongoDB will not use that index". But i don't understand why is the third query result set can't be obtained from the sparse index in my db.
Is this a bug or am i doing something wrong?
- duplicates
-
SERVER-12684 incorrect result and index not used for $ne with sparse index
- Closed
- related to
-
SERVER-13986 Creating a sparse index makes the not equals query to return diferent results.
- Closed
-
SERVER-12735 Improve negation-related tree normalization during query canonicalization
- Backlog