Skip to content

$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

OperatorMeaningExample
eqEqual$filter=name eq 'Widget'
neNot equal$filter=name ne 'Widget'
gtGreater than$filter=price gt 10
geGreater than or equal$filter=price ge 10
ltLess than$filter=price lt 100
leLess than or equal$filter=price le 100
inIn list$filter=status in ('active','pending')

Logical operators

OperatorMeaningExample
andLogical AND$filter=price gt 10 and active eq true
orLogical OR$filter=origin eq 'lhr' or origin eq 'jfk'
notLogical NOT$filter=not contains(name,'test')

String functions

FunctionSQL mappingExample
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 NULL

Precedence 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
  • has operator (enum flags)

These limitations apply to the built-in FilterToEloquent and FilterToQuery translators. Custom resolvers may implement additional filter support.

OData: MIT | Core: BSL 1.1 | SDK: Commercial License