curl通过HTTP协议与Elasticsearch通信报错解决方案
一、请求:curl -XGET 'http://localhost:9200/_count?pretty' -d '{ "query":{"match_all":{} } }'
返回错误信息:
{
“error":"Content-Type header [application/x-www-form-urlencoded] is not supported",
"status":406
}
解决方式:添加 -H "content-Type:application/json"即可处理,curl -XGET 'http://localhost:9200/_count?pretty'
-H "content-Type:application/json" -d '{ "query":{"match_all":{} } }'