Azure搜索中使用tokenizer“keyword_v2”的客户分析器不会返回包含空格的搜索测试的结果

时间:2018-04-14 15:44:40

标签: lucene azure-search

我在Azure搜索索引中有一个名为machineTag的字段,其中包含以下详细信息:

"analyzers": [
{
    "@odata.type": "#Microsoft.Azure.Search.CustomAnalyzer",
    "name": "SWMLuceneAlongWithCustomHyphenAnalyser",
    "tokenizer": "keyword_v2",
    "tokenFilters": [
        "lowercase"
    ],
    "charFilters": []
}

,索引是

    {
        "name": "machineTag",
        "type": "Edm.String",
        "searchable": true,
        "filterable": true,
        "retrievable": true,
        "sortable": true,
        "facetable": true,
        "key": false,
        "indexAnalyzer": null,
        "searchAnalyzer": null,
        "analyzer": "SWMLuceneAlongWithCustomHyphenAnalyser"
    }

现在,这个字段中有一个名为“high Machine”的文本,但是我的查询:

search=machineTag:/.*high\%20machine.*/&$count=true&$top=100&$skip=0&$filter=machineTag%20ne%20null&$queyType=full

不会返回任何结果。我在这里做错了吗?

如果我测试分析器,它会返回如下所示的结果,我的理解是转义空间应返回结果: 输入正文:

  {
     "analyzer":"SWMLuceneAlongWithCustomHyphenAnalyser",
     "text": "high Machine"
  }

响应:

 {
    "@odata.context": "https://abcd/$metadata#Microsoft.Azure.Search.V2016_09_01.AnalyzeResult",


  "tokens": [
        {
            "token": "high machine",
            "startOffset": 0,
            "endOffset": 12,
            "position": 0
        }
    ]
}

以另一种方式提问,该字段将包含带空格和*字符的文本。如果分析仪错误,请建议..

1 个答案:

答案 0 :(得分:2)

您指定的查询有效,查询参数名称中有拼写错误。将 queyType 替换为 que r yType

search=machineTag:/.*high\%20machine.*/&$count=true&$top=100&$skip=0&$filter=machineTag%20ne%20null&queryType=full