elasticsearch 仅 return 总点击数

elasticsearch return total hits only

我想向 ELS 发送查询 return 只有总命中数。

没有别的

如果我得到回复就​​好了

{   "took": 1111,   "timed_out": false,   "_shards": {
    "total": 9,
    "successful": 9,
    "failed": 0   },   "hits": {
    "total": 731552,   
 }

我只想打印731552

现在我只发送:

卷曲http://server:9200/games_profilder/_search

谢谢

您可以为此使用 response filtering

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

这将产生

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

如果你真的只想得到总数,你可以像这样用 jq 管道结果:

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

这只会产生数字 731552