首页 > 解决方案 > 转义特殊字符和使用 Azure 搜索选择正确分析器的问题

问题描述

我正在使用 Azure 索引进行索引搜索。

我创建了用于转义的自定义SWMLuceneAlongWithCustomHyphenAnalyser分析器-(特殊字符),如下所示

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

例如转义 - 我的索引搜索查询是。

&search=lowerSystemID:/.*ryan\-yeti\-win10.*/lowerMachineTag:/.*ryan\-yeti\-win10.*/&$select=lowerProductKey,lowerSystemID,lowerMachineTag&$filter=(lowerSystemID ne null)&$count=true&$top=999&queryType=full&$skip=0

此查询返回预期结果。

但是我们遇到了查询值的问题!@#$%^&*()*^w

如果存在,它应该返回数据,否则显示零结果。现在它返回所有记录。下面是转义所有特殊字符后的查询。不知道我在这里做错了什么,或者分析器可能不是正确的:

&search=lowerSystemID:/.*\!\@\#\$\%\^\&\*\(\)\*\^w.*/lowerMachineTag:/.*\!\@\#\$\%\^\&\*\(\)\*\^w.*/&$select=lowerProductKey,lowerSystemID,lowerMachineTag&$filter=(lowerSystemID ne null)&$count=true&$top=999&queryType=full&$skip=0

任何建议都会有所帮助!

标签: azure-cognitive-search

解决方案


推荐阅读