問題:利用Elasticsearch -head插件不能查看數據或者在Elasticsearch -linux的curl命令操作時總是提示:
{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}
解決辦法:
1、進入head安裝目錄;
2、cd _site/
3、編輯vendor.js 共有兩處
①、6886行 contentType: "application/x-www-form-urlencoded,改成:contentType: "application/json;charset=UTF-8"
②、7574行 var inspectData = s.contentType === "application/x-www-form-urlencoded" &&,改成:var inspectData = s.contentType === "application/json;charset=UTF-8" &&
原因2:在curl中,是在報文Content-type的參數:application/x-www-form-urlencoded不支持Json發送。需要改成application/Json。所以需要添加參數 ; -H ‘Content-Type: application/json’或者直接在終端操作命令時修改操作命令:
原命令:
curl -XGET 'http://localhost:9200/_count?pretty' -d ' { "query": { "match_all": {} } } '
修改后命令:
curl -XGET 'localhost:9200/_count?pretty' -H 'content-Type:application/json' -d '
{
"query":{
"match_all":{}
}
或:curl -H "Content-Type: application/json" http://localhost:9200/tmdb/_search?pretty -d ' {"query": {"match_all": {}}}'