I am using Azure.search.mocument.models.SearchOptions and I'm trying to set the filter to not(answer in ('X', 'Y'))
. So it looks like this:
SearchOptions searchOptions = new SearchOptions()
.setFilter("not(answer in ('X', 'Y')");
What I've tried:
Also, .setFilter("answer eq 'X')
works just fine.
I get this error when doing the first two filters (not the "nin" one):
Invalid expression: Expression contains an unsupported OData language feature.
But in the Azure Search documentation, it says that "not" is supported: https://learn.microsoft.com/en-us/azure/search/search-query-odata-logical-operators
Is there any way I can do a "not in" expression rather than doing an answer ne X and answer ne Y
filter?
Can you try the following:
SearchOptions searchOptions = new SearchOptions()
.setFilter("answer ne 'X' or answer ne 'Y');
This should filter out all the documents where the answer is not equal to X
or Y
.
You can read more about OData comparison operators here: https://learn.microsoft.com/en-us/azure/search/search-query-odata-comparison-operators.