【发布时间】:2020-11-03 02:28:28
【问题描述】:
我试图让 Elastic Search 在城市列表中进行语音搜索。我的目标是即使用户使用不正确的拼写也能找到匹配的结果。
我已经完成了以下步骤:
-
删除域
curl -X DELETE "localhost:9200/city/" -
创建新域
curl -X PUT "localhost:9200/city/?pretty" -H 'Content-Type: application/json' -d' { "settings": { "index": { "analysis": { "analyzer": { "my_analyzer": { "tokenizer": "standard", "filter": [ "lowercase", "my_metaphone" ] } }, "filter": { "my_metaphone": { "type": "phonetic", "encoder": "metaphone", "replace": true } } } } }, "mappings": { "properties": { "name": { "type": "text", "analyzer": "my_analyzer" } } } }' -
填写一些样本数据
curl -X PUT "localhost:9200/city/_doc/1?pretty" -H 'Content-Type: application/json' -d' { "name":"Mayrhofen" } ' curl -X PUT "localhost:9200/city/_doc/2?pretty" -H 'Content-Type: application/json' -d' { "name":"Ischgl" } ' curl -X PUT "localhost:9200/city/_doc/3?pretty" -H 'Content-Type: application/json' -d' { "name":"Saalbach" } ' -
在城市中搜索 - 在这里我得到一个结果
curl -X GET ""localhost:9200/city/_search?pretty" -H 'Content-Type: application/json' -d' { "query":{ "query_string":{ "query":"Mayrhofen" } } } '
我尝试使用 Mayerhofen 进行查询,并期望得到与使用 Mayrhofen 相同的结果。 Ischgl 和 Ichgl 或 Saalbach 和 Salbach 的问题相同。
我的错误在哪里?有什么消息吗?
【问题讨论】:
标签: amazon-web-services elasticsearch elasticsearch-phonetic