'Partial term search for a field with "/" special character in azure cognitive search

I am seeing some issues when trying to search for a field that has “/” special character in it in Azure Search.

I am listing the queries I have tried below, so looking for help in figuring out the issue.

There is a field called CustomProperty with keyword analyzer, so the field doesn’t get tokenized on special characters.

CustomPropertyWithKeywordAnalyzer

The value of customProperty is objectId/70efb434-40c4-4314-a53c-179700480ca8

search=/.*object.*70ef.*/&queryType=full&searchFields=customProperty query works

QueryResult

search=/.*70efb434-40c4-4314-a53c-179700480ca8.*/&queryType=full&searchFields=customProperty query works

QueryResult

Starts to get near to “/” the query doesn’t work, while “object.*” query works above. search=/.*objectI.*70ef.*/&queryType=full&searchFields=customProperty doesn’t work

QueryResult

search=/.*objectI.*/&queryType=full&searchFields=customProperty doesn’t work

QueryResult

search=/.*objectId\/70efb4.*/&queryType=full&searchFields=customProperty https://docs.microsoft.com/en-us/azure/search/search-query-partial-matching#about-partial-term-search says to escape / with , but that also doesn’t work. doesn’t work

QueryResult

simple(not full-lucene) also doesn't work search=objectId\/70efb4*&searchFields=customProperty

QueryResult



Solution 1:[1]

The issue you're running into isn't caused by the / but instead is caused by a mismatch in the casing between your query and the data in your index. Partial term searches, like the regex searches that you're doing, are automatically lowercased. However, they keyword analyzer you're using doesn't lowercase the text. That means that in your index, the data looks like objectId but your query is being automatically lowercased to objectid. That mismatch is what's causing your query to not return results. There are more details here: https://docs.microsoft.com/azure/search/search-query-partial-matching

For your use case, I'd recommend the following analyzer:

"analyzers": [
        {
            "@odata.type": "#Microsoft.Azure.Search.CustomAnalyzer",
            "name": "custom-keyword",
            "tokenizer": "keyword_v2",
            "tokenFilters": [
                "lowercase"
            ],
            "charFilters": []
        }
    ]

I tested your queries with that analyzer and that sample data and they all worked using that analyzer.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Derek Legenzoff