Elasticsearch不支持Content-Type标头[application/x-www-form-urlencoded] [英] Content-Type header [application/x-www-form-urlencoded] is not supported on Elasticsearch

查看:237
本文介绍了Elasticsearch不支持Content-Type标头[application/x-www-form-urlencoded]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经有ElasticSearch 5.2,并且刚升级到6.0.

I used to have ElasticSearch 5.2, and just upgraded to 6.0.

我正在尝试按照指南这里,但出现错误

I am trying to create an index template following guide here, but got error

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'

To fix this, add curl option -H 'Content-Type: application/json'

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

This error is due to strict content-type checking introduced in ElasticSearch 6.0, as explained in this post

从Elasticsearch 6.0开始,所有包含主体的REST请求也必须提供该主体的正确内容类型.

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

这篇关于Elasticsearch不支持Content-Type标头[application/x-www-form-urlencoded]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆