Elasticsearch 添加索引返回406

作者: hedeqiang

发布时间: 2018-09-06 13:26:52

Index and Query a Document

使用如下命令进行添加索引时,将会返回 406

curl -XPUT localhost:9200/cu-XPUT localhost:9200/customer/_doc/1?pretty -d '{"name":"hedeqiang"}'

该命令将会返回以下内容:

{
  "error" : "Content-Type header [application/x-www-form-urlencoded] is not supported",
  "status" : 406
}

解决方式: 使用以下命令,使用 -H 指定请求头

curl -H "Content-Type: application/json" -XPUT localhost:9200/customer/_doc/1?pretty -d '{"name":"hedeqiang"}'

正常情况下会返回:

{
  "_index" : "customer",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 0,
  "_primary_term" : 1
}

关于极客返利

极客返利 是由我个人开发的一款网课返利、返现平台。包含 极客时间返现、拉勾教育返现、掘金小册返现、GitChat返现。目前仅包含这几个平台。后续如果有需要可以考虑其他平台。 简而言之就是:你买课,我返现。让你花更少的钱,就可以买到课程。

https://geek.laravelcode.cn

https://geek.idaka.ink

版权许可

本作品采用 知识共享署名 4.0 国际许可协议 进行许可。

转载无需与我联系,但须注明出处,注明文章来源 Elasticsearch 添加索引返回406