single quote in group names

Allen Han 1 Reputation point
2020-07-29T21:20:40.843+00:00

I have group names contain single quote. I was trying to use double quotes to escape it, but the security search did not work. Seemed the filter was not working at all. Anyone saw similar case? Any suggestion to check or address it?

Thanks

Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
1,060 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. brtrach-MSFT 16,586 Reputation points Microsoft Employee
    2020-08-01T07:09:15.583+00:00

    @Allen Han You'll need to replace the single quote with two single quotes.

    filterString.Append(($"Provider eq '{provider.ProviderName.replace("'","''")}'"));  
    

    Let us know if you have further questions or concerns.


  2. Allen Han 1 Reputation point
    2020-08-04T13:40:42.183+00:00

    Using two single quotes worked for the quote's case. Thanks!

    After further test, it turned out the issue was actually coming from the space within the group name, not the single quote. Looks like ACS tokenized the group name and treated space as delimiter.

    Is there a way to specify a special analyzer for the group_ids field so that the whole string should be treated as non-parsing entity?

    Thanks

    0 comments No comments

  3. Allen Han 1 Reputation point
    2020-08-05T16:42:29.82+00:00

    After following this link: https://learn.microsoft.com/en-us/azure/search/search-analyzers, I was able to specify analyzer to the group_ids field such as:

    {    
      "name": "group_ids",    
      "type": "Collection(Edm.String)",    
      "filterable": true,    
      "retrievable": true,    
      "analyzer": "keyword"     
    },       
    

    But the search still not working. Even when I tested with https://learn.microsoft.com/en-us/rest/api/searchservice/test-analyzer, it showed the whole string was not altered at all.

    Any suggestions to check it further?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.