Software AG Products 10.7 | Integrating On-Premises and Cloud Applications | Service Development | Working with OData Services | Querying Data Using $filter
 
Querying Data Using $filter
You can use filter expressions in OData requests to filter and return only those results that match the expressions specified. You do this by adding the $filter system query option to the end of the OData request.
You can specify the $filter query option in an OData request as follows:
http://host:port/odata/parent_context/resource?$filter=expressions
Here, parent_context is the OData service node in the Integration Server namespace, resource refers to the name of an entity type or a collection of instances of an entity type, and expressions are the filter expressions.
Integration Server supports the following logical operators:
Operator
Description
Example
Requests...
eq
Equals
http://localhost:5555/odata/
OData.svc/Customers?
$filter=Name eq ‘Smith’
All customers whose name is ‘Smith’.
ne
Not equal
http://localhost:5555/odata/
OData.svc/Customers?
$filter=Name ne ‘Smith’
All customers whose name is not ‘Smith’.
gt
Greater than
http://localhost:5555/odata/
OData.svc/Products?
$filter=Price gt 1000
All products with price greater than 1000.
ge
Greater than or equal
http://localhost:5555/odata/
OData.svc/Products?
$filter=Price ge 1000
All products with price greater than or equal to 1000.
lt
Less than
http://localhost:5555/odata/
OData.svc/Products?
$filter=Price lt 1000
All products with price less than 1000.
le
Less than or equal
http://localhost:5555/odata/
OData.svc/Products?
$filter=Price le 1000
All products with price less than or equal to 1000.
and
Logical and
http://localhost:5555/odata/
OData.svc/Products?
$filter=Category eq 'laptop'
and Price lt 1000
All products of category laptop and price less than 1000.
or
Logical or
http://localhost:5555/odata/
OData.svc/Customers?
$filter=City eq 'Paris' or
City eq 'London'
All customers from the city of Paris or London.
Note:
You can also use custom filters instead of OData built-in filters while using the $filter system query option. To use your custom filters, set the Use custom filter property of the OData service to True. You can then specify custom filter queries as the value for the $filter parameter of the _retrieve and _update OData service implementations.