30

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.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Emmanuel Villegas
  • 1,374
  • 3
  • 12
  • 19
  • 5
    Look a tutorial Odata: http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/part2-url-conventions/odata-v4.0-errata03-os-part2-url-conventions-complete.html#_Toc444868693 – KingRider Aug 07 '17 at 14:15

5 Answers5

50

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

Knelis
  • 6,782
  • 2
  • 34
  • 54
John Little
  • 778
  • 6
  • 14
23
$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

David Lopes
  • 520
  • 3
  • 10
10

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

scher
  • 1,813
  • 2
  • 18
  • 39
7

Use

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

This includes first index and above.

4

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