1

I have an index set up with about 1000 items in it. I am doing the following API call to get the results back.

        var parameters = new SearchParameters
        {
            Select = new[] { "pageTitle", "pageUrl", "metaDescription" },
            Top = 5,
            QueryType = QueryType.Full
        };
        var results = indexer.Documents.Search<IndexPageData>("childrens bed frames~", parameters);

It's working as expected from a getting data back point of view. But if I misspell 'Childrens' with something like 'Childrns' or 'Chidrens'... Was I under the impression the fuzzy/mis-spellings search would understand and return the same results or very similar?

But I get completely different results and they are very poorly matched compared to the correctly spelled term.

Am I missing something with the API?

SynozeN Technologies
  • 1,337
  • 1
  • 14
  • 19
YodasMyDad
  • 9,248
  • 24
  • 76
  • 121
  • I think it's probably a grammar issue (key word here being single): To do a fuzzy search, use the tilde "~" symbol at the end of a single word with an optional parameter, a number between 0 and 2 (default), that specifies the edit distance. For example, "blue~" or "blue~1" would return "blue", "blues", and "glue". Fuzzy search can only be applied to terms, not phrases. Fuzzy searches can expand a term up to the maximum of 50 terms that meet the distance criteria. https://learn.microsoft.com/en-us/rest/api/searchservice/lucene-query-syntax-in-azure-search – Aaron May 25 '17 at 13:34
  • I am using the tilde with the default value, which is 2? But misspellings tend to be mixed up letters or .. ie .. ei or missing letters... I was under the impression Azure search handled things like this? – YodasMyDad May 25 '17 at 13:50
  • 1
    Search only "chldren~" ... it should work. You have 3 words in your string. – Aaron May 25 '17 at 13:54
  • 1
    Or, try "childrn~ bed~ frames~" maybe... It's definitely grammar. I'm not at my desk, but you should be able to search for an example. – Aaron May 25 '17 at 13:56
  • Thanks. That now works as expected! – YodasMyDad May 25 '17 at 14:46
  • 1
    Do you mind if I create an answer based on comments? – Aaron May 25 '17 at 15:24
  • Please do, it's a good answer. – Yahnoosh May 25 '17 at 19:27
  • Of course. I'll mark it as the answer – YodasMyDad May 26 '17 at 06:26
  • thanks for your questions. had tough times investigating why fuzzy search doesn't work at all for me, even with tildas. Found out that fuzzy search requires QueryType = QueryType.Full in parameters. – Igor V Savchenko May 02 '19 at 12:41

2 Answers2

2

As per the comment from Aaron. I was missing the tilda at the end of each word

childrens~ bed~ frames~

This is now catching things like "childrn bed frames" etc...

YodasMyDad
  • 9,248
  • 24
  • 76
  • 121
0

"Fuzzy" Search is currently only available for the suggester, see this. You will have to rely on your language analyser to properly tokenize the word and provide you with the expected result.

K Sant
  • 9
  • 1
  • This is incorrect, it is supported in Azure. See https://learn.microsoft.com/en-us/rest/api/searchservice/lucene-query-syntax-in-azure-search#bkmk_fuzzy – MGot90 Jan 04 '19 at 18:56
  • It's not entirely incorrect, actually. You can't use fuzzy search using azure search sdk without messing with ~ tildas. For suggestions you can use SuggestParameters with option UseFuzzyMatching. SuggestParameters doesn't have such parameter. – Igor V Savchenko May 02 '19 at 12:17