Curl with elasticsearch

Hi everyone,
My pc is windows 10. I want to use curl command to get the data from elasticsearch, but I have some problems.
this is my curl command (a small test):
curl -GET "http://localhost:9200/_search" -d'{"query": {"match_all": {}}}'

and the cmd show the error:
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"request [
/_search] contains unrecognized parameter: ['{query:]"}],"type":"illegal_argumen
t_exception","reason":"request [/_search] contains unrecognized parameter: ['{qu
ery:]"},"status":400}curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] empty string within braces in column 2

could anyone help me?

thank you in advance.

curl on windows is often a pain.

I'd recommend using Kibana Dev Console instead.

May be you are missing space?

curl "http://localhost:9200/_search" -d '{"query": {"match_all": {}}}'

BTW this is the same as:

curl "http://localhost:9200/_search"

thanks for your reply.
I try to add the space:
curl "http://localhost:9200/_search" -d '{"query": {"match_all": {}}}'

and the error became to this one:
{"error":"Content-Type header [application/x-www-form-urlencoded] is not support
ed","status":406}curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] empty string within braces in column 2

You need to add -H 'Content-Type: application/json'

the same error ><
{"error":"Content-Type header [application/x-www-form-urlencoded] is not support
ed","status":406}curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] empty string within braces in column 2

this is my command:
curl "http://localhost:9200/_search" -d '{"query": {"match_all": {}}}' -H 'Content-Type: application/json'

It means that -H 'Content-Type: application/json' did not work. Look at the curl documentation for windows. May be another option.

Again, you will save your time by starting a Kibana instance.

ok, thank you!
the query in kibana is great to work.
and I need to get the data from curl tool. so I am trying.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.