1

I'm trying to filter an azure search edm.collection to return results if any of multiple strings are in the collection. I can only get it working when querying for one item, which isn't good enough for my use case. I can't find syntax for querying multiple parameters.

filter += "FirmTypes / any (x: x eq 'Big 4')";

the above works and returns all of the documents where firm type is Big 4.

I've tried multiple ways (some below) to filter for more than one parameter with no success

//filter += " OR any (x: x eq 'Industry')";
//filter += "FirmTypes / any (x: x eq 'Industry')";
//filter += "FirmTypes / any (x: x eq 'Big 4', 'Industry', 'PLC')"
//filter += "FirmTypes / any (x: x eq 'Big 4' or 'Industry' or 'PLC')"
//filter += "FirmTypes / any (x: x eq 'Big 4') or (x: x eq 'Industry')"
//filter += "FirmTypes / any (x: x eq 'Big 4')|(x: x eq 'Industry')"

Can anybody kindly point me in the right direction? Thank you in advance.

Pete Herc
  • 163
  • 10

2 Answers2

4

The best way to filter over multiple values is to use the new search.in function:

FirmTypes/any(x: search.in(x, 'Big 4|Industry', '|'))

For large numbers of values, search.in is significantly faster than using a combination of or and eq, and it can handle a much larger number of values without hitting the hard limits on filter complexity.

Bruce Johnston
  • 8,344
  • 3
  • 32
  • 42
  • Great, Thankyou. I'd read the search.in syntax on msdn but couldn't didn't appreciate it was used within the any expression, so my version wasn't working. Appreciate you taking the time to answer. – Pete Herc Nov 16 '17 at 08:15
0

Got it as soon as I posted. If anybody else has same issue

"FirmTypes / any (x: x eq 'Big 4') or FirmTypes / any (x: x eq 'Industry')"
Pete Herc
  • 163
  • 10