【发布时间】:2019-11-30 04:08:24
【问题描述】:
当我在 ElasticSearch 文档 (https://www.elastic.co/guide/en/elasticsearch/reference/6.7/search-suggesters-completion.html) 中描述的建议中使用完成类型时,我无法获得所有匹配的单词(每个文档我只能得到一个匹配的单词)
我在我的 ElasticSearch 6.7.2(这是 AWS 目前可用的最新版本)上测试以下命令:
如果存在则删除索引
curl http://localhost:9200/test -H 'Content-Type: application/json' -X DELETE
创建索引
curl http://localhost:9200/test -H 'Content-Type: application/json' -X PUT -d '
{
"mappings": {
"page": {
"properties": {
"completion_terms": {
"type": "completion"
}
}
}
}
}
'
索引文档
curl http://localhost:9200/test/_doc/1 -H 'Content-Type: application/json' -X PUT -d '
{
"completion_terms": ["restaurant", "restauration", "réseau"]
}'
检查文档是否存在
curl http://localhost:9200/test/_doc/1 -H 'Content-Type: application/json'
使用补全
curl -X GET "localhost:9200/test/_search?pretty=true" -H 'Content-Type: application/json' -d'
{
"_source": ["suggestExact"],
"suggest": {
"suggestExact" : {
"prefix" : "res",
"completion" : {
"field" : "completion_terms"
}
}
}
}
'
结果是:
{
"took" : 6,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : 0.0,
"hits" : [ ]
},
"suggest" : {
"suggestExact" : [
{
"text" : "res",
"offset" : 0,
"length" : 3,
"options" : [
{
"text" : "restaurant",
"_index" : "test",
"_type" : "page",
"_id" : "1",
"_score" : 1.0,
"_source" : { }
}
]
}
]
}
}
我想获取所有匹配的单词(这里,每个文档我最多得到一个结果)
在示例中,缺少“restauration”和“réseau”
我做错了吗?
【问题讨论】:
标签: elasticsearch aws-elasticsearch