Azure搜索,精确短语匹配 [英] Azure Search, exact phrase matching

查看:79
本文介绍了Azure搜索,精确短语匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个天蓝色的Web应用程序,其中有一个搜索框,当我们输入带有双引号的文本(例如"App Service")时,它将列出带有"App Service"的记录,但是它还包括在单词之间包含特殊字符的记录,例如应用程序/服务".我们希望搜索引擎返回与搜索短语完全匹配的记录(不包括在搜索词之间具有特殊字符的记录).

We have a azure web application where in there is one search box, when we enter text with double quotes like "App Service" it list records with "App service" however it also includes records having special characters in between the words like "App/Service". We want the search engine to return records that match the search phrase exactly (don't include records having special characters in between the search terms).

推荐答案

在您的情况下,standard分析器将术语 App/Service 分解为两个单独的术语 app 服务.这就是为什么短语"App Service"将文档与 App/Service 匹配的原因-两种版本在搜索引擎中看起来都是相同的.

In your case the standard analyzer breaks the term App/Service into two individual terms app and service at indexing time. That's why the phrase "App Service" matches the document with App/Service - both versions look the same to the search engine.

如果术语应用程序/服务构成字段的全部内容,则可以使用keyword分析器将该字段的内容作为单个标记进行索引.在此处了解更多信息: Azure中的自定义分析器搜索.

If the term App/Service constitutes the entirety of the content of a field, you can index the content of that field as a single token using the keyword analyzer. Learn more here: Custom Analyzers in Azure Search.

如果术语 App/Service 作为句子的一部分出现,则keyword分析器将不是一个好的选择.在这种情况下,您可以将/字符替换为standard标记符不会分割的另一个字符,例如:_.为此使用mappping字符令牌过滤器:

The keyword analyzer won't be a good option if the term App/Service occurs as a part of a sentence. In that case you can replace the / character with another character that the standard tokenizer doesn't split on, for example: _. Use the mappping character token filter for that:

charFilters: [
  {
    "name":"map_char_mapping",
    "@odata.type":"#Microsoft.Azure.Search.MappingCharFilter",
    "mappings":[ "/=>_" ]
  }     
] 

以下文章将帮助您了解在搜索和索引编制时如何应用词法分析器:

The following post will help you understand how lexical analyzers are applied at search and indexing time: How to practially use a keywordanalyzer in azure-search?

这篇关于Azure搜索,精确短语匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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