嗨!
我从ES 5迁移到ES 6,并尝试像往常一样使用curl push 以下映射:
"mappings" : {
"mee": {
"properties" : {
"ind1" : { "type" : "float" },
"ind2" : { "type" : "float" },
"ind3" : { "type" : "float" },
"time" : { "type" : "date", "format" : "HH:mm:ss" },
"name" : { "type" : "string" },
"timestamp" : { "type" : "date", "format" : "yyyy-MM-dd HH:mm:ss" },
}
}
使用以下命令:
$ curl -XPUT "http://localhost:9200/mee/" -d @config/ESConf/ESUpdate.conf
{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}
并且由于标题是必需的(根据ES 6的required),我做了以下工作:
$ curl -XPUT "http://localhost:9200/mee/" -H 'Content-Type: application/json' -d @config/ESConf/ESUpdate.conf
{"error":{"root_cause":[{"type":"not_x_content_exception","reason":"Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"}],"type":"not_x_content_exception","reason":"Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"},"status":500}
现在我完全迷路了...我只是不明白这个错误...我做错了吗?
谢谢 !
最佳答案
映射的语法有问题。将整个映射定义括在大括号中,并确保括号配对。还要在最后一个属性后删除多余的逗号。这是正确的请求正文的略有格式的示例:
{
"mappings": {
"mee": {
"properties": {
"ind1": {
"type": "float"
},
"ind2": {
"type": "float"
},
"ind3": {
"type": "float"
},
"time": {
"type": "date",
"format": "HH:mm:ss"
},
"name": {
"type": "string"
},
"timestamp": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
}
}
}
}
}
关于curl - 通过curl的PUT索引映射导致错误(Content-Type header 修复不起作用),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47782278/