According to https://docs.microsoft.com/en-us/azure/search/query-lucene-syntax special charachters should be escaped:
Special characters that require escaping include the following: + - & | ! ( ) { } [ ] ^ " ~ * ? : \ /
The issue is that some of them are search operators: + - | ".
Same issue with quotations marks " . I need to distinguish case when they are operators: "banking account" and banking account(without quotations) are 2 different queries.
And for example quotations could be inches: ten" (ten inches).
Would be nice to have like this:
string searchPhrase = banking -account // no need to escape because "-" is a search operator
string searchPhrase = "banking :-\) sucks" // needed to escape because "-" is not a search operator
string searchPhrase = bank "account opening" // no needed to escape
string searchPhrase = 100\" // inches not a search operator must be escaped
Written above was tested with search query against Azure search index:
"search=banking -account" and "search=banking \-account" (with escaped "-")produce different number of results.
Is there a way to programmatically decide when special charachter needs escaping or am I missing something obvious here?