luceneazure-cognitive-search

Is it possible to use fuzzy search (~) in filters for Azure AI Search along with wildcards (*)?


This question is for using Azure AI Search. I am using both the searchable features as well as filter features for the same input. The reason for using both is that using only the fuzzy search gives me too broad of a result. For example, when inputting multiple words, fuzzy searching them gives me results that only have one of the words in it, whereas I want results that include all of the words.

I.e. A search for dot urethane should ONLY return results where the name has both dot and urethane

So using filters and search.ismatch() queries solves this. However, I want to be able to still use fuzzy search for possible misspellings. How am I able to use fuzzy search within a filter?

Ex: a search for dot urethine (misspelling of urethane)

What I am currently doing:

{
    "search": "dot~ urethine~",
    "filter" : "search.ismatch('/.*dot.*/', 'name', 'full', 'all') and 
                search.ismatch('/.*urethine.*/', 'name', 'full', 'all')"
}

This search/filter combo works well, but only if the words are correctly spelled. Otherwise, the filter will take out all of the results, since "urethine" isn't in the name.

What I was hoping was possible but doesn't work:

{
    "search": "dot~ urethine~",
    "filter": "search.ismatch('/.*dot~.*/', 'name', 'full', 'all') and
               search.ismatch('/.*urethine~.*/', 'name', 'full', 'all')"
}

--

I am just using the Azure AI Search index search explorer in JSON view mode to test the query out.


Solution

  • I think I figured it out after posting. You can just use the tilde and not a wildcard which works with this contains query.

    ex: search.ismatch('dot~', 'name', 'all', 'full') and search.ismatch('urethine~', 'name', 'all', 'full')