elasticsearch - Elasticsearch 不支持内容类型 header [application/x-www-form-urlencoded]

标签 elasticsearch curl mime-types content-type http-put

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

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

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"
        }
      }
    }
  }
}'

最佳答案

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


此错误是由于 ElasticSearch 6.0 中引入的严格内容类型检查引起的,如 this post 中所述

Starting from Elasticsearch 6.0, all REST requests that include a body must also provide the correct content-type for that body.

关于elasticsearch - Elasticsearch 不支持内容类型 header [application/x-www-form-urlencoded],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47544966/

相关文章:

php - 在 PHP 中使用 Curl 单击按钮并获得响应

mime-types - MIME 类型中 "vnd"的含义是什么?

http-headers - 哪种MIME类型适合.exe文件?

apache-spark - 使用ES-Spark连接器创建嵌套对象数组

java - 如何根据某些参数动态生成 Elasticsearch 查询

php - curl 异常 : [curl] 51: SSL: certificate verification failed

asp.net-mvc - Asp.net MVC 页面为图像文件提供 Mime 类型警告

amazon-web-services - 从浏览器访问 Amazon AWS elasticsearch Kibana

elasticsearch - 如何在Elastic Search中使用默认值更新整个索引的字段值

windows - git 克隆错误 : RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054