Is there a LIKE operator in odata filter?

66,438

Solution 1

Consider contains: $filter=contains(CompanyName,'Alfreds')

Solution 2

$filter=substringof('Alfreds', CompanyName) 

for more details see: http://www.odata.org/documentation/odata-version-3-0/url-conventions/ --> 5.1.2.4. Canonical Functions

Solution 3

For me worked $filter=indexof(CompanyName, 'Alfreds') gt -1. This is case sensitive.

Solution 4

Use

$filter=indexof(CompanyName, 'Alfreds') gt -1

This includes first index and above.

Solution 5

For oData v2, you can try:

$filter=substringof('sites/my folder/subfolder', FileRef) eq true

Samples using public oData Service:

https://services.odata.org/Northwind/Northwind.svc/Customers?$filter=substringof('Futterkiste',CompanyName) eq true

https://services.odata.org/Northwind/Northwind.svc/Customers?$filter=substringof('London',City) eq true

https://services.odata.org/Northwind/Northwind.svc/Customers?$filter=substringof('w',ContactName) eq true and substringof('London',City) eq true

Ref: enter link description here

Share:
66,438

Related videos on Youtube

Emmanuel Villegas
Author by

Emmanuel Villegas

Updated on October 16, 2020

Comments

  • Emmanuel Villegas
    Emmanuel Villegas over 3 years

    I'm trying to filter my data through OData where the field FileRef contains lets say "/The root path/folder/subfolder", I tried with substringof like so:

    $filter=substringof("sites/my folder/subfolder", FileRef)

    But it seems doesn´t work, so I wonder if is there an operator like or something that i can use for achieve this.

  • mydoghasworms
    mydoghasworms about 4 years
    I think contains is supported only from Odata 3 or 4. It's not available in version 2, AFAIK.