Operators
Reference for every filter operator supported by KelpFilter, with examples.
Every filter clause is { field, op?, values }. The op field selects how Kelp compares values against indexed documents. When op is omitted it defaults to =.
Operator table
| Operator | Meaning | values shape | Example |
|---|---|---|---|
= | Equals / in-list (default) | One or more strings - matches any | { field: 'vendor', op: '=', values: ['globex', 'initech'] } |
!= | Not equals / exclusion | One or more strings - excludes all | { field: 'status', op: '!=', values: ['discontinued'] } |
> | Greater than (numeric) | One string - values[0] | { field: 'price', op: '>', values: ['0'] } |
>= | Greater than or equal (numeric) | One string - values[0] | { field: 'price', op: '>=', values: ['50'] } |
< | Less than (numeric) | One string - values[0] | { field: 'price', op: '<', values: ['200'] } |
<= | Less than or equal (numeric) | One string - values[0] | { field: 'price', op: '<=', values: ['150'] } |
range | Inclusive numeric range | Two strings - [min, max] | { field: 'price', op: 'range', values: ['50', '150'] } |
= with multiple values is an OR/IN match within one clause: values: ['globex', 'initech'] means the field must equal globex OR initech. See Combining filters for AND semantics across fields.
= - equals / in-list
The default operator. Pass a single value for an exact match, or multiple values for an OR/IN match. Multiple values within one = clause are disjunctive - the document must match any one of them.
// exact match
{ field: 'status', values: ['ACTIVE'] }
// in-list: vendor is globex OR initech
{ field: 'vendor', op: '=', values: ['globex', 'initech'] }!= - not equals / exclusion
Excludes documents whose field value matches any of the listed values. Useful for hiding specific product types, tags, or statuses.
// exclude discontinued products
{ field: 'status', op: '!=', values: ['discontinued'] }
// exclude gift cards by product type
{ field: 'productType', op: '!=', values: ['Gift Card'] }
// exclude a tag
{ field: 'tags', op: '!=', values: ['hidden'] }>, >=, <, <= - numeric comparisons
Each accepts a single value in values[0]. Use these when you have only an upper or lower bound, not both.
// price is at least 50
{ field: 'price', op: '>=', values: ['50'] }
// price is no more than 150
{ field: 'price', op: '<=', values: ['150'] }
// in-stock: inventory total greater than zero
{ field: 'variantInventoryTotal', op: '>', values: ['0'] }Numeric values are passed as strings (the values array is always string[]). The index field must be numeric for comparison operators to work correctly.
range - inclusive numeric range
range requires exactly two values: [min, max]. Both bounds are inclusive. Use this instead of two separate >= / <= clauses when you have both bounds - it is more expressive and sends a single clause.
// price between 50 and 150, inclusive
{ field: 'price', op: 'range', values: ['50', '150'] }
// rating between 3.5 and 5
{ field: 'rating', op: 'range', values: ['3.5', '5'] }See Price & range filtering for the full pattern, including how to fall back to individual bound operators when only one bound is set.
AND vs OR semantics
All filter clauses in the filters array are ANDed together - every clause must match. Values within a single = clause are ORed.
// brand is (globex OR initech) AND status is ACTIVE
filters: [
{ field: 'vendor', op: '=', values: ['globex', 'initech'] },
{ field: 'status', op: '=', values: ['ACTIVE'] },
]There is no OR across different fields. To express "field A = x OR field B = y" you would need to handle that at the application layer before sending the query.