curl – 不支持Content-Type标头[application / x-www-form-urle
参见英文答案 >
ElasticSearch – Content-Type header [application/x-www-form-urlencoded] is not supported????????????????????????????????????2个
我已将Elasticsearch(版本5.5)集成到Gitlab中并尝试使用它.这是我从外部Windows客户端发送的命令: curl -XGET gitlab.server:9200/ -H 'Content-Type: application/json' -d '{"query": {"simple_query_string" : {"fields" : ["content"],"query" : "foo bar -baz"}}}' 但它不起作用.在客户端我得到这些错误:
在/var/log/elasticsearch/elasticsearch.log中的服务器上,我看不到日志消息. 但是,从linux服务器运行与上面相同的命令会给我一个没有错误的响应: { "name" : "name","cluster_name" : "elasticsearch","cluster_uuid" : "uuid","version" : { "number" : "5.5.0","build_hash" : "260387d","build_date" : "2017-06-30T23:16:05.735Z","build_snapshot" : false,"lucene_version" : "6.6.0" },"tagline" : "You Know,for Search" } 我尝试将http.content_type.required:true添加到elasticsearch.yml,但问题是一样的.那么,我在这里做错了什么?为什么我从Windows客户端获得“不支持Content-Type标头”?我怎么解决这个问题? 将’改为’后如下: curl -XGET gitlab.server:9200/ -H "Content-Type: application/json" -d "{"query": {"simple_query_string" : {"fields" : ["content"],"query" : "foo bar -baz"}}}" 我接受了这个回复: { "name" : "name",for Search" } curl: (6) Could not resolve host: bar 解决方法
将封闭引号从’更改为’后,转义参数中使用的引号“如下:
curl -XGET gitlab.server:9200/ -H "Content-Type: application/json" -d "{"query": {"simple_query_string" : {"fields" : ["content"],"query" : "foo bar -baz"}}}" alternative是将json放入文件中,并使用@前缀作为参数. json.txt { "query": { "simple_query_string" : { "fields" : ["content"],"query" : "foo bar -baz" } } } 并运行curl如下: curl -XGET gitlab.server:9200/ -H "Content-Type: application/json" -d @json.txt (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |