$filter
The $filter query option restricts the set of returned entities. The filter expression is parsed into an AST and translated to SQL WHERE clauses by the resolver.
Syntax
GET /odata/Products?$filter=price gt 10
GET /odata/Products?$filter=name eq 'Widget'Comparison operators
| Operator | Meaning | Example |
|---|---|---|
eq | Equal | $filter=name eq 'Widget' |
ne | Not equal | $filter=name ne 'Widget' |
gt | Greater than | $filter=price gt 10 |
ge | Greater than or equal | $filter=price ge 10 |
lt | Less than | $filter=price lt 100 |
le | Less than or equal | $filter=price le 100 |
in | In list | $filter=status in ('active','pending') |
Logical operators
| Operator | Meaning | Example |
|---|---|---|
and | Logical AND | $filter=price gt 10 and active eq true |
or | Logical OR | $filter=origin eq 'lhr' or origin eq 'jfk' |
not | Logical NOT | $filter=not contains(name,'test') |
String functions
| Function | SQL mapping | Example |
|---|---|---|
contains(prop, 'val') | LIKE '%val%' | $filter=contains(name,'Widget') |
startswith(prop, 'val') | LIKE 'val%' | $filter=startswith(name,'Wid') |
endswith(prop, 'val') | LIKE '%get' | $filter=endswith(name,'get') |
Null handling
$filter=description eq null → WHERE description IS NULL
$filter=description ne null → WHERE description IS NOT NULLPrecedence and grouping
Use parentheses to control precedence:
$filter=(price gt 10 and price lt 100) or name eq 'Special'Without parentheses, and binds tighter than or.
What is NOT supported
- Lambda operators (
any,all) on navigation properties - Arithmetic operators in filter position (
add,sub,mul,div,mod) - Date/time functions (
year(),month(), etc.) in filter position - Geo-spatial functions
hasoperator (enum flags)
These limitations apply to the built-in FilterToEloquent and FilterToQuery translators. Custom resolvers may implement additional filter support.