Search code examples
searchlucenefuzzy-searchazure-cognitive-search

Fuzzy search on a collection of strings


I'm using Azure Search and I have an index that has a field named 'keywords', which holds keywords (with type Collection(Edm.String)) related to a single document. I want to be able to use fuzzy search on my documents and as I understood from this link, all I have to do is put a '~' character to the end of my search query. However, this doesn't seem to work in my case.

I have a few documents in my index and one of them includes "fun" in its keywords. When I search for "run" with fuzzy search, I expect to see the documents with keyword "run", as well as "fun". If I know correctly, the edit distance between "fun" and "run" is only 1, which seems to be the default distance Azure Search's fuzzy search uses. Am I doing anything wrong here?

Or does the type Collection(Edm.String) not support fuzzy search? The attributes for 'keywords' are Searchable, Filterable and Retrievable.

Edit: I'm using the Standard Lucene Analyzer for the 'keywords' field. When I send the query

https://fakename.search.windows.net/indexes/fakeindex/docs?api-version=2016-09-01&search=run~

I would expect to get the following document as its keywords contain "fun"

"keywords": [
    "balloon",
    "message",
    "text",
    "monster",
    "fun",
    "evil",
    "mad",
    "cartoons",
    "funny"
  ]

Solution

  • The fuzzy search feature is only supported in Lucene query syntax in Azure Search. Please specify queryType=full in the query string.