首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >Elasticsearch 添加索引返回406

Elasticsearch 添加索引返回406

作者头像
hedeqiang
发布于 2019-12-17 22:08:01
发布于 2019-12-17 22:08:01
1.9K0
举报
文章被收录于专栏:LaravelCodeLaravelCode

Elasticsearch 添加索引返回406

Index and Query a Document

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

代码语言:javascript
复制
curl -XPUT localhost:9200/cu-XPUT localhost:9200/customer/_doc/1?pretty -d '{"name":"hedeqiang"}'

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

代码语言:javascript
复制
{
  "error" : "Content-Type header [application/x-www-form-urlencoded] is not supported",
  "status" : 406
}

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

代码语言:javascript
复制
curl -H "Content-Type: application/json" -XPUT localhost:9200/customer/_doc/1?pretty -d '{"name":"hedeqiang"}'

正常情况下会返回:

代码语言:javascript
复制
{
  "_index" : "customer",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 0,
  "_primary_term" : 1
}           
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除
目录
  • Elasticsearch 添加索引返回406
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档