I have a query that runs from code (with an external library), and now I am trying to run it directly from the terminal, using the curl command:
This is the original query:
{
"index": [
"logstash-*2021.08.21*",
"logstash-*2021.08.22*"
],
"ignore_unavailable": true,
"allow_no_indices": true,
"type": "doc",
"body": {
"query": {
"bool": {
"must": [
{
"range": {
"@timestamp": {
"gte": "now-24H/H"
}
}
}
]
}
}
}
}
But running the folwing query from Linux terminal:
curl -u "*******:****************" -XGET "https://XXXXXXXXXXXXXXXXXXXXXXXXXX:9200/logstash-
*/_search"
-H 'Content-Type: application/json'
-d '
{
"index": [
"logstash-*2021.08.21*",
"logstash-*2021.08.22*"
],
"ignore_unavailable": true,
"allow_no_indices": true,
"type": "doc",
"body": {
"query": {
"bool": {
"must": [
{
"range": {
"@timestamp": {
"gte": "now-24H/H"
}
}
}
]
}
}
}
}
'
returns error:
{"error":{"root_cause":[{"type":"parsing_exception","reason":"Unknown key for a START_ARRAY in [index].","line":1,"col":10}],"type":"parsing_exception","reason":"Unknown key for a START_ARRAY in [index].","line":1,"col":10},"status":4
It is worth noting that running the folwing query without additional parameters, returns correct results:
curl -u "elastic:****************" -XGET "https://XXXXXXXXXXXXXXXXXXXXXXXXXX:9200/logstash-*/_search"
What do I need to change in the terminal query?