azure-cognitive-search - 如何停止 zh-Hans.microsoft 分析器匹配几乎任何东西
问题描述
我无法让 Azure 搜索中的中文语言学正常工作。它出乎意料地匹配几乎任何东西。例如,我有一个最小的测试用例,其中使用 zh-Hans.microsoft 分析器的属性包含以下内容:
米/6克
这将意外匹配M1.6的查询。这怎么可能?即使我的查询将被标记为 M1 和 6,它仍然不应该将我的内容与标记 M 和 6g 匹配?
我测试了 20 种不同的分析仪。它们都不会导致匹配,除非我使用 zh-Hans.microsoft。
最小指数
{
"@odata.context": "https://{{SEARCH_SVC}}.{{DNS_SUFFIX}}/$metadata#indexes/$entity",
"@odata.etag": "\"0x8D8761DCBBCCD00\"",
"name": "products",
"defaultScoringProfile": null,
"fields": [
{
"name": "Id",
"type": "Edm.String",
"facetable": false,
"filterable": true,
"key": true,
"retrievable": true,
"searchable": false,
"sortable": true,
"analyzer": null,
"indexAnalyzer": null,
"searchAnalyzer": null,
"synonymMaps": [],
"fields": []
},
{
"name": "KeywordsZhCn",
"type": "Collection(Edm.String)",
"facetable": true,
"filterable": true,
"retrievable": true,
"searchable": true,
"analyzer": "zh-Hans.microsoft",
"indexAnalyzer": null,
"searchAnalyzer": null,
"fields": []
}
],
"scoringProfiles": [],
"corsOptions": null,
"suggesters": [],
"analyzers": [],
"tokenizers": [],
"tokenFilters": [],
"charFilters": [],
"encryptionKey": null
}
最少的文件
{“价值”:[{“@search.action”:“mergeOrUpload”,“Id”:“1”,“KeywordsZhCn”:[“M / 6g”]
}]}
示例查询 https://{{SEARCH_SVC}}.{{DNS_SUFFIX}}/indexes/products/docs?search=M1.6&$count=true&$select=Id,KeywordsZhCn&searchMode=all&queryType=full&api-version=2020-06- 30-Preview&featuresMode=enabled&scoringStatistics=global
featuresMode 选项已启用,因此我看到了意外匹配发生的位置。
{
"@odata.context": "https://<my-search-service>.search.windows.net/indexes('products')/$metadata#docs(*)",
"@odata.count": 1,
"value": [
{
"@search.score": 0.25811607,
"@search.features": {
"KeywordsZhCn": {
"uniqueTokenMatches": 1.0,
"similarityScore": 0.25811607,
"termFrequency": 1.0
}
},
"Id": "1",
"KeywordsZhCn": [
"M / 6g"
]
}
]
}
我已经在 Stack Overflow 上搜索过类似的案例,但我只能找到大约一年前我自己的一篇帖子,我在 Azure 搜索中遇到了疯狂的中文回忆问题,参考。中文查询导致出乎意料的高召回率
分析的输出用分析的输出更新我的问题。
使用 zh-Hans.microsoft 分析器分析内容“M / 6g”会产生以下标记:
"tokens": [
{
"token": "m",
"startOffset": 0,
"endOffset": 1,
"position": 0
},
{
"token": "6g",
"startOffset": 4,
"endOffset": 6,
"position": 1
}
]
查询 M1.6 产生:
"tokens": [
{
"token": "m",
"startOffset": 0,
"endOffset": 1,
"position": 0
},
{
"token": "1.6",
"startOffset": 1,
"endOffset": 4,
"position": 1
},
{
"token": "nn1d6",
"startOffset": 1,
"endOffset": 4,
"position": 1
}
]
解决方案
推荐阅读
- python - 如何使用 sklearn 的 GraphicalLasso 和 NetworkX 从(加权)邻接矩阵估计网络结构?
- javascript - Tradingview如何获取数据来刷新价格?
- node.js - 无法在使用 react 构建的简单博客中添加新文章
- sql - 如何使用 SQL 和通配符搜索 %?
- hash - 如何用盐创建 sha256 哈希
- javascript - 如何让两个 div 屏幕显示和隐藏在相同的高度
- ios - 如何创建一个带有可选辅助 View 参数的 SwiftUI 视图?
- python - 如何用 unittest 覆盖我的 Python 代码
- sql - 根据 jsonb 数组中的嵌套键查找行
- javascript - 在二叉搜索树上查找最小高度 - 如何跟踪高度的倒数第二次更新