elasticsearch仅返回总点击数 [英] elasticsearch return total hits only

查看:140
本文介绍了elasticsearch仅返回总点击数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将查询发送给ELS,该查询仅返回总点击数.

i want to send query to ELS that return only the total hits.

没有其他内容

就像我得到回应一样

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

我只想打印731552

现在我只发送:

curl http://server:9200/games_profilder/_search

谢谢

推荐答案

您可以使用这将产生

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

如果您真的只想得到总数,则可以使用 jq 传递结果像这样:

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'

,这只会产生数字731552

这篇关于elasticsearch仅返回总点击数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆