Filter Syntax
Usage
After an API url which supports filters, add the 'filters' querystring part, e.g. myapiurl?filters=... or myapiurl?x=y&filters=...
Filter syntax consists of one or more filters, separated by tilde symbols (~)
Each filter itself consists of three parts: propert(ies), filter operator, value(s)
The parts are separated by underscores (_), e.g. property_operator_value
If a value contains an underscore, it should be 'escaped' by making it a double underscore, e.g. myapiurl?filters=field_eq_some_value should be myapiurl?filters=field_eq_some__value
Filters can be run on one or more fields, separated by commas (,) e.g.
myapiurl?filters=field1_eq_value
myapiurl?filters=field1,field2_eq_value
NOTE that the fields MUST be the same type. You cannot, for example, search across a string column and a date/time column
Most filters are single-value. The exception is the 'OR' filter, which has multiple values separated by commas (,)
e.g. property_OR_x,y,z
Note that the value(s) must match the type of property that is being used to sort or filter. In the case of date/time, it must be 'parseable' by .Net
Performance considerations
Filters support properties on nested object, e.g. nestedobject.property, however it is highly likely that filtering based on these properties will perform much slower as they will be executed using in-memory filtering rather than directly against the underlying data set
For strings, some filters are available in case-insenstive form, but may perform slower than the case sensitive alternatives.
Available Filters
- EQ equals
-
Does a complete 'equals' of the given value to the property value.
-
Example: /data/meter/list?filters=meterid_eq_20
-
EQ* equals (case insensitive)
-
Does a complete 'equals' of the given value to the property value, case insensitive. Can only be used with strings. Note that case insensitive calls MAY not be supported by certain data sources, so should be avoided unless absolutely necessary.
-
Example: /data/meter/list?filters=meterid_eq*_tEsT
-
CTNS contains
-
This only applies to string properties. It looks for the given string inside the properties.
-
Example: /data/meter/list?filters=meterid_ctns_0
-
CTNS* contains (case insensitive)
-
This only applies to string properties. It looks for the given string inside the properties, case insensitive. Can only be used with strings. Note that case insensitive calls MAY not be supported by certain data sources, so should be avoided unless absolutely necessary.
-
Example: /data/meter/list?filters=meterid_ctns*_tEsT
-
GT greater than
-
Does a greater than check for properties greater than the given value.
-
Example: /data/meter/list?filters=lastreading.reading_gt_500
-
GTEQ greater than or equal
-
Does a greater than check for properties greater than or equal to the given value.
-
Example: /data/meter/list?filters=lastreading.reading_gteq_500
-
LT less than
-
Does a less than check for properties less than the given value.
-
Example: /data/meter/list?filters=lastreading.reading_lt_500
-
LTEQ less than or equal
-
Does a less than check for properties less than or equal to the given value.
-
Example: /data/meter/list?filters=lastreading.reading_lteq_500
-
OR or
-
Matches a property with at least one value from a set of values
-
Example: /data/meter/list?filters=meterid_or_10,20,30,40,50
-
OR* or (case insensitive)
-
Matches a property with at least one value from a set of values, case insensitive. Can only be used with strings. Note that case insensitive calls MAY not be supported by certain data sources, so should be avoided unless absolutely necessary.
-
Example: /data/meter/list?filters=meterid_or_aB,cD,eF