Azure搜索-与第一个或单个结果完全匹配

问题描述:

我正在使用基于丰富的Lucene查询解析器语法的Azure搜索.我将〜1"定义为距离的一个符号的附加参数.但是我面临的问题是,即使存在完全匹配的实体,实体也不是有序的. (例如,"blue〜1"将返回"blues","blue","glue".或者在搜索产品SKU(例如"P002")时,我会得到结果"P003","P005","P004","P002","P001","P006") 所以我的问题是:有什么方法可以定义完全匹配的实体必须位于列表的第一位,或者即使我使用模糊搜索〜1"还是单个搜索结果?

I'm using Azure Search based on the rich Lucene Query Parser syntax. I defined to "~1" as additional parameter to one symbol for distance ). But I faced with problem, that the entity is not ordered even if there is exact match. (For example,"blue~1" would return "blues", "blue", "glue". Or when searching product SKU like "P002", I would get result "P003", "P005", "P004", "P002", "P001", "P006" ) So my question: is there some way to define, that the entity with exact match must be first in list, or be singl search result even then I'm using fuzzy search "~1"?

使用

With Lucene Query syntax you can boost individual subqueries, for example: term^2 | term~1 - this translates to "find documents that match 'term' OR 'term' with edit distance 1, and score the exact matches higher relative to fuzzy matches by a factor of two.

search=blue^2|blue~1&queryType=full

由于文档得分是术语频率和文档反向频率的功能.如果模糊子查询将输入项扩展为文档语料库中非常独特的项,则可能需要增加提升因子(在我的示例中为2).通常,依靠相关性分数进行排序不是一个实际的想法.请参阅以下帖子中的我的答案以获取更多信息: Azure搜索得分

There is no guarantee that the exact match will always be first in the results set as the document score is a function of term frequency and inverse document frequency. If the fuzzy sub-query expands the input term to a term that's very unique in your document corpus you may need to bump the boosting factor (2 in my example). In general, relying on the relevance score for ordering is not a practical idea. Take a look at my answer in the following post for more information: Azure Search scoring

让我知道这是否有帮助