question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Azure Search - Cannot $filter by fields containing special characters, even when escaped

See original GitHub issue

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

  1. Create an index with the document mentioned in the description.
  2. Using the SDK, set SearchParams.Filter to search.in(FirmName, 'Crazy Charz Inc. '' \+ \- \&\& \! \( \) \{ \} \[ \] \^ \" \~ \* \? \: \\ \/', '|'). (That’s how the value looks when I inspect in in VS.)
  3. Observe that no results are returned (not an error; see SO link below for details on what happens in the Search Explorer with the same query).

Environment:

  • Microsoft.Azure.Search v10.1.0
  • Windows 10
  • Search is performed in a .NET Standard 2.0 library and consumed by a .NET Core 3.1 library.
  • Visual Studio 16.4.3

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!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
brjohnstmsftcommented, Feb 10, 2020

@PrimeHydra I agree it isn’t discoverable enough. It’s probably in a note somewhere. I’ll change the filter docs to make it more obvious.

We’re 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’t have to deal with it anymore.

1reaction
brjohnstmsftcommented, Feb 11, 2020

@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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure search not working with special characters
But let's say I want to search all jobs with C# on the title or description I do the following search using the...
Read more >
Partial term search and patterns with special characters ...
The solution is to invoke an analyzer during indexing that preserves a complete string, including spaces and special characters if necessary, so ...
Read more >
When to escape characters
When to escape characters. When using SPL2, use the backslash character ( \ ) to ignore characters that have special meaning in a...
Read more >
Searching JIRA issues for special characters (in text fields) ...
Searching JIRA issues for special characters (in text fields) does not work, even if these characters have been properly escaped in a quick,...
Read more >
Using special characters in queries
Coveo doesn't index special characters. Therefore, you can't search for a special character or for a term containing a special character, such as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found