问题描述
我希望能够同时处理模糊搜索和同义词.我尝试了几种方法,但无法正常工作.
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
和这个同义词规则:
white,light
black,dark
如果我执行查询 queryType = full& search = light
或 queryType = full& search = white
,它将始终返回light和white值.所以同义词起作用了.
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.
如果我执行查询 queryType = full& search = light〜1
,那么只会返回light.但是白色在哪里?
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?
推荐答案
同义词扩展不适用于通配符搜索词;前缀,模糊和正则表达式项不会扩展.
Synonym expansions do not apply to wildcard search terms; prefix, fuzzy, and regex terms aren't expanded.
如果您需要执行一个应用同义词扩展和通配符,正则表达式或模糊搜索的查询,则可以使用 OR 语法组合查询.
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
或
queryType=full&search=light OR light~1
如果您使用的是Lucene查询语法
if you're using Lucene query syntax
这篇关于在Azure搜索中使用Lucene模糊搜索和同义词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!