Custom OData queries¶
Both the asset-centric OData service and the data-modeling OData service support custom queries to filter properties and retrieve specific datasets.
Custom query URLs¶
Asset-centric OData service example¶
To filter on a resource type property:
Where:
{resourceType}
: a resource type, such asAssets,TimeSeries,Events, etc.{Filter}
: theODatafilter expression.
Data-modeling OData service example¶
To filter on a view property in a data model:
Where:
{view}
: the name of theviewin your data model.{Filter}
: theODatafilter expression.
Custom query examples¶
Simple equality filter¶
An equality filter uses the format AttributeName eq 'AttributeValue'
:
Data modeling filtering¶
A filter applied directly to a property of a data model view:
Metadata filtering¶
For metadata, filtering is performed on properties nested inside the metadata object:
Combined filter¶
Using functions in filters¶
OData supports functions like startswith
, endswith
, and contains
.
For example, to filter time series where ExternalId
starts with 'Sensor'
:
Note: Not all functions are supported for pushdown to CDF. Check the filtering capabilities of the specific resource type.
Combining multiple query parameters¶
You can combine multiple query options to refine your data retrieval.
For example, to retrieve assets where Name
starts with 'Pump'
, select only Id
and Name
, and order by Name
:
Debugging custom queries¶
- Use separate tools: Tools like Fiddler allow you to inspect the HTTP traffic between your client and the server.
- Check the filter syntax: Ensure that your filters are correctly formatted according to the
ODataspecification. - Review supported filters: See Filter items in data models and Filtering asset-centric resource types to learn about the filtering capabilities supported by the
ODataservices.
Limitations¶
Not all OData functions and features are supported. For detailed information on supported features and limitations, refer to the individual service documentation .