在Azure搜索中使用StartsWith进行搜索 [英] Search using StartsWith in Azure Search

查看:69
本文介绍了在Azure搜索中使用StartsWith进行搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这种情况下,我必须使用Azure搜索使用供应商名称搜索供应商.例如,下面是供应商列表.

I have scenario where I have to search the Vendors using Vendor Names using Azure Search. For Example Below is the List Of Vendors.

  1. Infosys Technologies Limited
  2. Infosys BPM Limited
  3. Infor解决方案
  4. Infosys企业技术
  5. 戴尔计算机
  6. 第一信息系统

我的搜索场景是

  1. 当Searchtext是 Info 时,它应返回1,2,3,4
  2. 当Searchtext为 Infosys 时,它应返回1,2,4
  3. 当Searchtext是 Infosys Tech 时,它应该只返回1而不是4
  1. when Searchtext is Info it should return 1,2,3,4
  2. when Searchtext is Infosys it should return 1,2,4
  3. when Searchtext is Infosys Tech it should return only 1 not 4

我还尝试了供应商名称"字段上的关键字分析器,它也没有给出我期望的结果.基本上,我希望searchtext从供应商名称字段(startswith)的开头而不是在供应商名称的每个单词(Standard.Lucene Analyzer在每个单词上搜索)中搜索.

I also tried keyword analyzer on Vendor Name Field and it also does not give the result I expected. Basically I want the searchtext to search from start of the Vendor Name field(startswith) and not on each word(Standard.Lucene Analyzer searches on every word) of Vendor Name Separately.

在这种情况下,请问您能如何帮助我查询框架?

Can You Please Help me in this case on how to frame my query.

推荐答案

来自Nate Ko的答案

From Nate Ko's answer here:

您似乎想在整个范围内发出前缀搜索查询 字段值不在字段中的各个词条上.在这种情况下 您需要使用关键字分析器,以便整个字段值为 标记化为单个标记.例如,假设"16th Ave SE"为 输入,默认情况下,Azure搜索使用标准分析器并标记化 输入多个术语,如< 16th>,和前缀 搜索是基于标记化的术语进行的.如果您使用关键字 而不是分析器,将整个字段值标记为单个 标记为< 16th ave se>,并且前缀搜索search = 16th *只会找到 带有以前缀开头的字段的文档.同样, 通过正则表达式搜索后缀搜索=/.* ave/将仅查找包含字段的文档 以后缀结尾.以下是有关的相关问题 stackoverflow.

It looks like you want to issue a prefix search query on the entire field value not on the individual terms in the fields. In such case, you need to use keyword analyzer so that the entire field value is tokenized into a single token. For example, given "16th Ave SE" as input, by default Azure Search uses standard analyzer and tokenizes the input into multiple terms as <16th>, , and the prefix search is issued on the tokenized terms. If you use the keyword analyzer instead, the entire field value is tokenized as the single token as <16th ave se> and a prefix search search=16th* will only find documents with field that starts with the prefix. Likewise, the suffix search via regex search=/.*ave/ will only find docs with fields that ends with the suffix. Below are related questions on stackoverflow.

http://stackoverflow.com/questions/40056213 /behavior-of-asterisk-in-azure-search-service/40137948#40137948

http://stackoverflow.com/questions/40857057 /如何在天蓝色搜索中实际使用关键字分析仪

这篇关于在Azure搜索中使用StartsWith进行搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆