问题
I created a new Azure Search Suggester but implemented Fuzzy search with the following code:
ISearchIndexClient indexClient = CreateSearchIndexClient();
var suggestParameters = new SuggestParameters();
suggestParameters.UseFuzzyMatching = true;
suggestParameters.MinimumCoverage = 100;
DocumentSuggestResult response = indexClient.Documents.Suggest(term, "suggester", suggestParameters);
IList<SuggestResult> results = response.Results;
The index contain the string "China", but when I search using the following "chn", no suggestion is return. I expect that fuzzy search will be able to return "China".
Searching for "chi" will return "China" as a suggestion correctly.
Can anyone advise what I am doing wrong? Thank you
回答1:
The short answer to your question is that we do not expect "chn" to return "china" as a result.
The long answer is: suggestions with fuzzy matching happen in two steps. The first step is attempting to "complete" the last term of the query by finding matching words that have that term as a prefix. Only then do the edit distance kicks in as the second step which is to expand each term in the query using an edit distance of 1.
Since the word "chn" is not a prefix to "china", it won't be returned part of the first step. Since "chn" is 2 edit distance away from "china", its not found in the second step either. On the other side, "chi" is a prefix to "china", so its found during the first step. I expect that if you run the search query with "chna", "china" would be succesfully returned.
Hope this answers your question.
来源:https://stackoverflow.com/questions/49126737/azure-search-suggester-fuzzy-not-returning-results