elasticsearch return total hits only

elasticsearch, kibana

Solution

You can use response filtering for this:

curl http://server:9200/games_profilder/_search?filter_path=hits.total

which will yield

{
  "hits": {
    "total": 731552
  }
}

If you really want to only get the total, you can pipe the result with `jq` like this:

curl http://server:9200/games_profilder/_search?filter_path=hits.total | jq '.hits.total'

and that will yield only the number `731552`

Problem

i want to send query to ELS that return only the total hits. without anything else like if i get the respone ``` { "took": 1111, "timed_out": false, "_shards": { "total": 9, "successful": 9, "failed": 0 }, "hits": { "total": 731552, } ``` i want to print only 731552 for now i just send : curl http://server:9200/games_profilder/_search thanks

Original source