curl - 通过curl的PUT索引映射导致错误(Content-Type header 修复不起作用)

标签 curl elasticsearch

嗨!

我从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/

相关文章:

php - 使用 HTTPS 让 cURL 在 PHP 中工作

json - 嵌套结构的 Elasticsearch 映射

php - 在不覆盖现有元素的情况下不能插入元素

python - Scrapy 帖子数据

wordpress - WP - 对外部 API 的 cURL 调用停止工作 - cURL 错误 60 : SSL certificate problem: certificate has expired

python - 如何读取通过附加行不断更新的文件?

php - PayPal 托管页面和定期计费(附加 : Recurring Billing Suspension)

ruby - 更新Elasticache记录而不完全替换它

elasticsearch - 尝试批量索引时,ElasticSearch引发达到索引字段限制的情况