问题
I want to be able to handle fuzzy search, as well as synonyms at the same time. I tried it in a several ways, but I cannot get it working.
I have these values in my index:
white
black
light
dark
and this synonym rules:
white,light
black,dark
If I perform the query queryType=full&search=light
or queryType=full&search=white
, it always returns both values, light and white.
So synonyms are working.
If I perform the query queryType=full&search=light~1
, then only light will be returned. But where is white?
Is the combination of fuzzy search and synonyms not possible yet, or am I doing something wrong?
回答1:
Synonym expansions do not apply to wildcard search terms; prefix, fuzzy, and regex terms aren't expanded.
If you need to do a single query that applies synonym expansion and wildcard, regex, or fuzzy searches, you can combine the queries using the OR syntax.
For example, to combine synonyms with fuzzy search you would need to have query like this:
search=light~1|light
or
queryType=full&search=light OR light~1
if you're using Lucene query syntax
来源:https://stackoverflow.com/questions/54082779/using-lucene-fuzzy-search-and-synonyms-with-azure-search