我正在尝试将完成建议器实现到elasticsearch服务器中的字段。当我尝试执行curl命令时
curl -X POST localhost:9200/anisug/_suggest?pretty -d '{
"test" : {
"text" : "n",
"completion" : {
"field" : "header"
}
}
}'
我得到一个例外:
ElasticSearchException [Field [header]不是完成建议 字段]。
我错过了什么?
答案 0 :(得分:4)
我认为,在定义 anisug 的映射时,您需要设置标题字段以完成建议。例如,您可以使用此
curl -X PUT localhost:9200/anisug/_mapping -d '{
"test" : {
"properties" : {
"name" : { "type" : "string" },
"header" : { "type" : "completion",
"index_analyzer" : "simple",
"search_analyzer" : "simple",
"payloads" : true
}
}
}
}'
同样,在索引数据时,您需要发送其他完成信息。有关详细信息,请访问this link