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

查看:41
本文介绍了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天全站免登陆