Describe the bug
When a filter query includes special characters that have been escaped with backslashes, as described in the SDK docs, it does not match fields containing the same text. (Also, single quote ' is apparently escaped by doubling it: ''.) In this case, the test document contains a field like:
"FirmName": "Crazy Charz Inc. ' + - && ! ( ) { } [ ] ^ \" ~ * ? : \\ /"
Expected behavior
The document above should be returned.
Actual behavior (include Exception or Stack Trace)
Instead, zero results are returned.
To Reproduce
SearchParams.Filter to search.in(FirmName, 'Crazy Charz Inc. '' \+ \- \&\& \! \( \) \{ \} \[ \] \^ \" \~ \* \? \: \\ \/', '|'). (That's how the value looks when I inspect in in VS.)Environment:
Also see this SO post.
Not to be confused with this feature request; the issue is that the filter doesn't work _even when escaping the characters_, not the need for a character-escaping method. Unless I'm doing something wrong, in which case, please tell me how to pass this test case. Thanks!
@PrimeHydra I wrote a console app to repro this behavior, and it's not a bug -- you're using the encoding scheme for a different query syntax (Simple query syntax for full-text search, not the OData syntax for filters). I provided more details in my answer on StackOverflow.
Thanks, @brjohnstmsft . Though this was user error, I feel the SDK docs could have made the filter expression character escaping a bit clearer? Three different syntaxes in one request is a lot for search newbies like myself to keep track of. :) Maybe I missed that page in the docs. Appreciate your response.
@PrimeHydra I agree it isn鈥檛 discoverable enough. It鈥檚 probably in a note somewhere. I鈥檒l change the filter docs to make it more obvious.
We鈥檙e currently working on a new generation of client libraries for Azure Cognitive Search, and one of our goals is to provide a mechanism for encoding each syntax so you don鈥檛 have to deal with it anymore.
@PrimeHydra I've updated the documentation. The changes should go live some time later today. I added a note at the top of the "simple" and "full Lucene" syntax pages explaining that they're not the same as the filter syntax, then added a section here explaining how string escaping works in OData.
Thanks for reporting this -- your feedback helps us make our service better!
Most helpful comment
@PrimeHydra I agree it isn鈥檛 discoverable enough. It鈥檚 probably in a note somewhere. I鈥檒l change the filter docs to make it more obvious.
We鈥檙e currently working on a new generation of client libraries for Azure Cognitive Search, and one of our goals is to provide a mechanism for encoding each syntax so you don鈥檛 have to deal with it anymore.