gpt4 book ai didi

elasticsearch 只返回总命中数

转载 作者:行者123 更新时间:2023-12-02 22:10:43 25 4
gpt4 key购买 nike

我想向仅返回总命中数的 ELS 发送查询。

没有别的

就像我得到回应一样

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

我只想打印 731552

现在我只是发送:

curl 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

关于elasticsearch 只返回总命中数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43758813/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com