> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognite.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom OData queries

> Use custom queries in asset-centric and data-modeling OData services to filter properties and retrieve specific datasets.

<a id="custom-query-urls" />

## Custom query URLs

<a id="asset-centric-odata-service-example" />

### Asset-centric OData service example

To filter on a resource type property:

```
GET .../{resourceType}/?$filter={Filter}
```

Where:

* `{resourceType}`: a resource type, such as <span translate="no">Assets</span>, <span translate="no">TimeSeries</span>, <span translate="no">Events</span>, etc.
* `{Filter}`: the <span translate="no">OData</span> filter expression.

<a id="data-modeling-odata-service-example" />

### Data-modeling OData service example

To filter on a <span translate="no">view</span> property in a data model:

```
GET .../{view}/?$filter={Filter}
```

Where:

* `{view}`: the name of the <span translate="no">view</span> in your data model.
* `{Filter}`: the <span translate="no">OData</span> filter expression.

<a id="custom-query-examples" />

## Custom query examples

<a id="simple-equality-filter" />

### Simple equality filter

An equality filter uses the format `AttributeName eq 'AttributeValue'`:

```
GET .../Assets?$filter=Name eq '23-TE-96116-04'
```

<a id="data-modeling-filtering" />

### Data modeling filtering

A filter applied directly to a property of a data model <span translate="no">view</span>:

```
GET .../City?$filter=iso2 eq 'MX'
```

<a id="metadata-filtering" />

### Metadata filtering

For metadata, filtering is performed on properties nested inside the metadata object:

```
GET .../Assets?$filter=MetaData/RES_ID eq '525283'
```

<a id="combined-filter" />

### Combined filter

```
GET .../Assets?$filter=MetaData/RES_ID eq '525283' and Name eq '23-TE-96116-04'
```

<a id="using-functions-in-filters" />

## Using functions in filters

<span translate="no">OData</span> supports functions like `startswith`, `endswith`, and `contains`.

For example, to filter time series where `ExternalId` starts with `'Sensor'`:

```
GET .../TimeSeries?$filter=startswith(ExternalId,'Sensor')
```

**Note**: Not all functions are supported for pushdown to <span translate="no">CDF</span>. Check the filtering capabilities of the specific resource type.

<a id="combining-multiple-query-parameters" />

## 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`:

```
GET .../Assets?$filter=startswith(Name,'Pump')&$select=Id,Name&$orderby=Name asc
```

<a id="debugging-custom-queries" />

## Debugging custom queries

* **Use separate tools**: Tools like [Fiddler](https://www.telerik.com/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 <span translate="no">OData</span> specification.
* **Review supported filters**: See [Filter items in data models](/cdf/dashboards/references/odata/dm_odata#filter-items-in-data-models) and [Filtering asset-centric resource types](/cdf/dashboards/references/odata/classic_odata#filtering-asset-centric-resource-types) to learn about the filtering capabilities supported by the <span translate="no">OData</span> services.

<a id="limitations" />

## Limitations

Not all <span translate="no">OData</span> functions and features are supported. For detailed information on supported features and limitations, refer to the individual [service documentation](/api-reference/concepts/20230101/api-description).
