The documentationhttp://docs.mongodb.org/manual/reference/operator/query/ne/ descrive the '$ne' function as:
$ne selects the documents where the value of the field is not equal (i.e. !=) to the specified value. This includes documents that do not contain the field.
However this becames is false when the queried value have an sparse index.
I can workarround but is a extrange behaivour when you don't expect it.
- is related to
-
SERVER-12684 incorrect result and index not used for $ne with sparse index
- Closed
-
SERVER-13324 Sparse index is not used to filter {field: {$ne: null}} queries
- Closed
-
SERVER-13939 Unexpected behavior of query planner with sparse indices
- Closed