How to use reserved words in Azure Search Filter?

Viewed 342

I am using Azure Search Filter option like follows

$filter=cityList/any(t: search.in(t, '1')) and name eq 'hi tech bar & restaurant' &search=*&scoringProfile=search-score&searchMode=Any&queryType=FULL

For all word filters except reserved words are working fine.

; / ? : @ = + &

Can anyone help me to find how to use reserved words in Azure Search Filters ??

Thanks in advance.

1 Answers

There are two levels of encoding to consider. First, the OData expression itself. I'm assuming you need to use the special characters in a string constant, in which case the only character you need to encode is single quote, which you can encode by doubling. For example: $filter=Name eq 'O''Neil'. The second level of encoding depends on whether you're using HTTP GET or POST for your search request. If you're using the Azure Search .NET SDK, it takes care of this detail for you. If you're using the REST API directly and you're using GET, you need to URL encode the filter expression. If you're using POST, you need to encode the filter expression as you would any other JSON string. For example, you need to encode \ as \ and " as \", etc. Hope this helps.

Related