Elasticsearch 不支持 Content-Type 标头 [application/x-www-form-urlencoded]

问题描述

解决此问题,请添加 curl 选项-H 'Content-Type: application/json'


错误是由于在 ElasticSearch 6.0 中引入了 本文所述

从 Elasticsearch 6.0 开始,所有包含正文的 REST 请求还必须为该正文提供正确的内容类型。

解决方法

我以前有 ElasticSearch 5.2,刚刚升级到 6.0。

我正在尝试按照此处的指南创建索引模板,但出现错误

Content-Type header [application/x-www-form-urlencoded] is not supported

我的查询是

curl -X PUT localhost:9200/_template/template_1 -d '
{
  "index_patterns": ["te*","bar*"],"mappings": {
    "type1": {
      "properties": {
        "host_name": {
          "type": "keyword"
        }
      }
    }
  }
}'