$ne (not equal) operator excludes documents where the field matches a specific value.
This operator works as a filter, removing matching documents from the result set rather than adding to it.
Because $ne only filters results, it must be combined with other conditions that produce a base result set.
A query using only $ne conditions returns no results since there is nothing to filter.
This behavior is similar to the $mustNot boolean operator,
but $ne operates at the field level rather than combining multiple conditions.
Compatibility
| Field Type | Supported |
|---|---|
| TEXT | Yes |
| U64/I64/F64 | Yes |
| DATE | Yes |
| BOOL | Yes |
Examples
- TypeScript
- Redis CLI