Azure 认知搜索中短语的通配符搜索

时间:2021-02-19 01:40:39

标签: lucene full-text-search azure-cognitive-search

我对 Azure 认知搜索比较陌生。所以仍在尝试了解适合我的用例的分析器是什么。

假设我的索引有以下公司名称文档

{
"id": 1
"CompanyName": "abc def ltd" 
},
{
"id":2
"CompanyName": "the abc ltd company" 
},
{
"id":3
"CompanyName": "abc foo def doo company" 
}

我的索引定义如下所示。

"Fields":[
                  {
                     "name":"Id",
                     "type":"Edm.Int32",
                     "key":true,
                     "retrievable":true,
                     "searchable":false,
                     "filterable":true,
                     "sortable":false,
                     "facetable":false,
                     "analyzer":null,
                     "searchAnalyzer":null,
                     "indexAnalyzer":null,
                  },
                  {
                     "name":"CompanyName",
                     "type":"Edm.String",
                     "key":false,
                     "retrievable":true,
                     "searchable":true,
                     "filterable":true,
                     "sortable":false,
                     "facetable":false,
                     "analyzer":"keyword",
                     "searchAnalyzer":null,
                     "indexAnalyzer":null,
                  }
               ]

除了关键字分析器,我也使用了模式分析器。

现在我的用例包括以下通配符查询。

abc%
%ltd
abc%def%company 

根据之前的一些堆栈溢出答案,我形成了这样的查询。

abc% --->

{
 "queryType": "full",
 "search": "/.abc.*/",
 "count":true,
 "top":10
}

但这会返回文档 ID {1, 2, 3} 的结果。而第二个文档不以“abc”开头。同样,我也无法用于其他查询。任何帮助将不胜感激。

0 个答案:

没有答案