Skip to main content
The $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 TypeSupported
TEXTYes
U64/I64/F64Yes
DATEYes
BOOLYes

Examples

// Exclude specific values
await products.query({
  filter: {
    name: "headphones",
    price: { $gt: 9.99, $ne: 99.99 },
  },
});