I am learning to use cURL and I need to run this in a console:
curl -XGET localhost:9200/library/book/_search?pretty=true -d { "query" : { "query_string" : { "query" : "title:crime" } } }
But this is a multi-line command. How can I handle it to send a complete command?
Note that I understand I can put the content after -d in a file to run this command.
The solution to this is to use the xargs command as shown alongside the curl command. The -P flag denotes the number of requests in parallel. The section <(printf '%s\n' {1.. 10}) prints out the numbers 1 – 10 and causes the curl command to run 10 times with 5 requests running in parallel.
Invoke curl.exe from a command window (in Windows, click Start > Run and then enter "cmd" in the Run dialog box). You can enter curl --help to see a list of cURL commands.
Sometime I have to use windows, try something like this :
curl -XPOST http://localhost:9200/_search -d^ "{^ \"query\": {^ \"query_string\": {^ \"query\": \"year:2003\"^ }^ }^ }"
^ to extend a command to next line and
\" to escape " on the json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With