Azure搜索中的前缀查询(*)不返回预期结果 [英] Prefix queries (*) in Azure Search don't return expected results
问题描述
使用 Microsoft搜索提供的Rest API在Azure上进行搜索时API 当搜索字符串包含"@"时,行为不正确.
While searching on azure using Rest API provided by Microsoft Search API Not behaving correctly when search string contains '@'.
示例:我在Azure文档中有3行 消费电子展 CES @ 123 CES @ 1234
Example: I've 3 rows in Azure Document CES CES@123 CES@1234
当我的搜索字符串是CES *时,则所有3个都是结果. 当我的搜索"字符串为CES @ 123 *时,则仅产生一个完全匹配的记录. 当我的搜索字符串为CES @ *时,没有结果.
When My search string was CES* then all 3 were the result. When My Search string was CES@123* then only one exact matching record was in result. When My Search string was CES@* then there was no result.
根据我对"CES @ *"搜索字符串的要求,所有3条记录都应作为结果集的一部分.
As per my requirement in case of "CES@*" search string, all 3 records should be part of result set.
我尝试用"(空格)代替@,它可以工作,但是我的数据包含@以进行搜索,我需要对此进行维护.
I've tried " "(space) in replacement of @ it works, but my data contains @ for search I need to maintain this.
我正在使用SearchMode:任何.
I'm using SearchMode:Any.
推荐答案
此行为是预期的.
不分析前缀查询的查询词.因此,在带有"CES @ *"的示例中,您正在搜索术语 CES @ ,而 @ 符号已从索引中的术语中去除:CES,123、1234
Query terms of prefix queries are not analyzed. Therefore, in your example with "CES@*" you are searching for term CES@ while the @ sign was stripped from the terms in the index: CES, 123, 1234.
以下摘录自如何全文搜索在Azure搜索中有效文章:
词法分析的例外情况
Exceptions to lexical analysis
词法分析仅适用于要求完整的查询类型 术语–术语查询或短语查询.它不适用于 术语不完整的查询类型-前缀查询,通配符查询, 正则表达式查询–或模糊查询.这些查询类型,包括 在我们的示例中,添加了带有条件air-condition *的前缀查询 直接进入查询树,绕过分析阶段.唯一的 对这些类型的查询字词执行的转换是小写的.
Lexical analysis applies only to query types that require complete terms – either a term query or a phrase query. It doesn’t apply to query types with incomplete terms – prefix query, wildcard query, regex query – or to a fuzzy query. Those query types, including the prefix query with term air-condition* in our example, are added directly to the query tree, bypassing the analysis stage. The only transformation performed on query terms of those types is lowercasing.
这篇关于Azure搜索中的前缀查询(*)不返回预期结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!