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
}