3

This is related to Azure's recently launched search service that is currently in preview form. I'm trying to figure out how to use OData's filter with collections. I know that I can do this:

$filter=Products/any(p: p eq 'WidgetA')

which will filter the Products collection by WidgetA. What I am trying to figure out is how to specify WidgetA OR WidgetB. I know that I can do this:

$filter=Products/any(p: p eq 'WidgetA') or Products/any(p: p eq 'WidgetB')

but thought there must be a more elegant or shorter way of doing this.

Kevin
  • 53
  • 1
  • 5

2 Answers2

3

Unfortunately, there is no as far as I know. The operator that addresses your requirement is 'in' but there is no in the protocol: http://docs.oasis-open.org/odata/odata/v4.0/os/part2-url-conventions/odata-v4.0-os-part2-url-conventions.html

One more thing: there should be a property follows the range variable:

http://host/service/Orders?$filter=Items/any(d:d/Quantity gt 100) 

in your case it should be "p/Name eq 'WidgetA'" or some other properties.

Tan Jinfu
  • 3,327
  • 1
  • 19
  • 20
0

IN operator is supported in OData v4.01

https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_BuiltinFilterOperations

Address/City in ('Redmond', 'London')
Xavier John
  • 8,474
  • 3
  • 37
  • 51