【发布时间】:2019-07-01 09:54:05
【问题描述】:
我在尝试使用 Azure 搜索的 Phoenetic 搜索时运气不佳。我的目标是制定一个索引配置,可以处理拼写错误并适应最终用户的语音搜索。
使用以下配置和示例数据,我试图搜索故意拼写错误的单词,例如“softvare”或“alek”。我得到了“alek”的结果,感谢语音分析器;但没有得到“softvare”的任何结果。
对于这个要求,拼音搜索似乎无法解决问题。
我发现的唯一选择是使用同义词映射。主要的缺陷是我无法将语音/自定义分析器与同义词一起使用:(
您会推荐哪些不同的策略来处理拼写错误?
使用的搜索查询
?api-version=2017-11-11&search=alec?api-version=2017-11-11&search=softvare
这里是索引配置
"name": "phonetichotels",
"fields": [
{"name": "hotelId", "type": "Edm.String", "key":true, "searchable": false},
{"name": "baseRate", "type": "Edm.Double"},
{"name": "description", "type": "Edm.String", "filterable": false, "sortable": false, "facetable": false, "analyzer":"my_standard"},
{"name": "hotelName", "type": "Edm.String", "analyzer":"my_standard"},
{"name": "category", "type": "Edm.String", "analyzer":"my_standard"},
{"name": "tags", "type": "Collection(Edm.String)", "analyzer":"my_standard"},
{"name": "parkingIncluded", "type": "Edm.Boolean"},
{"name": "smokingAllowed", "type": "Edm.Boolean"},
{"name": "lastRenovationDate", "type": "Edm.DateTimeOffset"},
{"name": "rating", "type": "Edm.Int32"},
{"name": "location", "type": "Edm.GeographyPoint"}
],
分析器(索引创建的一部分)
"analyzers":[
{
"name":"my_standard",
"@odata.type":"#Microsoft.Azure.Search.CustomAnalyzer",
"tokenizer":"standard_v2",
"tokenFilters":[ "lowercase", "asciifolding", "phonetic" ]
}
]
分析“软件”的 API 输入和输出
{
"analyzer":"my_standard",
"text": "software"
}
{
"@odata.context": "https://ctsazuresearchpoc.search.windows.net/$metadata#Microsoft.Azure.Search.V2017_11_11.AnalyzeResult",
"tokens": [
{
"token": "SFTW",
"startOffset": 0,
"endOffset": 8,
"position": 0
}
]
}
分析“softvare”的 API 输入和输出
{
"analyzer":"my_standard",
"text": "softvare"
}
{
"@odata.context": "https://ctsazuresearchpoc.search.windows.net/$metadata#Microsoft.Azure.Search.V2017_11_11.AnalyzeResult",
"tokens": [
{
"token": "SFTF",
"startOffset": 0,
"endOffset": 8,
"position": 0
}
]
}
我加载的示例数据
{
"@search.action": "upload",
"hotelId": "5",
"baseRate": 199.0,
"description": "Best hotel in town for software people",
"hotelName": "Fancy Stay",
"category": "Luxury",
"tags": ["pool", "view", "wifi", "concierge"],
"parkingIncluded": false,
"smokingAllowed": false,
"lastRenovationDate": "2010-06-27T00:00:00Z",
"rating": 5,
"location": { "type": "Point", "coordinates": [-122.131577, 47.678581] }
},
{
"@search.action": "upload",
"hotelId": "6",
"baseRate": 79.99,
"description": "Cheapest hotel in town ",
"hotelName": " Alec Baldwin Motel",
"category": "Budget",
"tags": ["motel", "budget"],
"parkingIncluded": true,
"smokingAllowed": true,
"lastRenovationDate": "1982-04-28T00:00:00Z",
"rating": 1,
"location": { "type": "Point", "coordinates": [-122.131577, 49.678581] }
},
使用正确的配置,即使是拼写错误的单词,我也应该得到结果。
【问题讨论】:
标签: azure elasticsearch lucene azure-cognitive-search