I would like to make cURL/Elasticsearch understand HTTP query parameters passed as normal strings while being url encoded by the command.
If I run this HTTP GET via cURL to submit the query to Elasticsearch:
curl \
-H 'Content-Type: application/json' \
-XGET '127.0.0.1:9200/movies/movie/_search?q=%2Byear%3A%3E1980+%2Btitle%3Astar%20wars&pretty'
Then I am able to retrieve the expected documents.
However if I run this cURL query:
curl \
-H 'Content-Type: application/json' \
--data-urlencode "pretty" \
--data-urlencode "q=+year:>1980 +title:star wars&pretty" \
-XGET '127.0.0.1:9200/movies/movie/_search'
Then I get this error:
{
"error": {
"root_cause": [{
"type": "json_parse_exception",
"reason": "Unrecognized token 'pretty': was expecting ('true', 'false' or 'null')\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@7856627; line: 1, column: 8]"
}],
"type": "json_parse_exception",
"reason": "Unrecognized token 'pretty': was expecting ('true', 'false' or 'null')\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@7856627; line: 1, column: 8]"
},
"status": 500
}
I am using:
cURLversion 7.47.0 which should understand the command parameter--data-urlencode- Elasticsearch 6.3.1