我在Elasticsearch 5.2中定义Context Suggester时遇到问题
这就是我尝试这样做的方法:
curl -XPUT 'localhost:9200/world/port/_mapping' -d '{
"port": {
"properties": {
"name": {
"type": "string"
},
"suggest": {
"type": "completion",
"analyzer": "simple",
"payloads": true,
"preserve_separators": true,
"preserve_position_increments": true,
"max_input_length": 50,
"contexts": {
"type": {
"name": "port_type",
"type": "category",
"path": "name"
}
}
}
}
}
}'
我玩了参数,但它总是以错误结束:
{
"error":
{
"root_cause":
[{"type":"parse_exception","reason":"missing [name] in context mapping"}],
"type":"parse_exception","reason":"missing [name] in context mapping"
},
"status":400
}
我试图通过谷歌搜索解决它,但没有成功。
邮件的名称是什么?
你能帮助我吗?
答案 0 :(得分:0)
以下是几个时刻:
context
应该是JSON数组"payload": true
是什么 - 我相信这是另外一件可以被淘汰的项目。在深入研究之后,我用以下命令实现了它:
curl -XPUT 'localhost:9200/world' -d '
{
"mappings" : {
"port": {
"properties": {
"name": {
"type": "string"
},
"suggest": {
"type": "completion",
"analyzer": "simple",
"preserve_separators": true,
"preserve_position_increments": true,
"max_input_length": 50,
"contexts": [
{
"name": "port_type",
"type": "category",
"path": "name"
}
]
}
}
}
}
}'