2

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.

vishnu
  • 223
  • 1
  • 4
  • 16

1 Answers1

1

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.

Yahnoosh
  • 1,932
  • 1
  • 11
  • 13
  • Thanks Yahnoosh. I am using .net SDK only. The problem I am facing is, if I use '&' in my 'filter eq' it's saying ""Invalid expression: There is an unterminated string literal at position 64 in 'cityList/any(t: search.in(t, '1')) and name eq". – vishnu Nov 29 '17 at 05:13
  • I am very disappointed that no one there to help me to find actual result. It's ok.. :( – vishnu Dec 01 '17 at 06:33
  • @Vishnu Please open a new issue on GitHub and include as much detail as possible about how you're using the .NET SDK and the exact string you're passing for the Filter property. Here is the link to the GitHub repo for the Azure .NET SDK: https://github.com/azure/azure-sdk-for-net/issues When you file the issue, please mention "Azure Search" in the title. – Bruce Johnston Dec 02 '17 at 22:45