tomer
(tomer zaks)
March 26, 2017, 7:17am
1
Hi,
When I type in:
GET filebeat-*/log/_search
{
"query": {
"term" : {"terminationCause": "SUCCESS"}
}
}
I get:
{
"took": 25,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 96,
"max_score": 3.1475947,
"hits": [
{
"_index": "filebeat-2017.03.19",
etc,
Now I want only to get the "total" field only to get the number 96.
I will be happy for any help
Hello, exist different json parsers, one of them: Redirecting to jqlang.github.io
jq '.hits' find necesary json param, then with grep and tr we will take total result:
curl -s localhost:9200/twitte/_search?q=: | jq '.hits' |grep total |tr -cd '[[:digit:]]'
i don't sure that this method is optimized, so you should found another solution.
But this - return correct result.
1 Like
dadoonet
(David Pilato)
March 26, 2017, 10:07am
3
1 Like
tomer
(tomer zaks)
March 26, 2017, 10:27am
4
Thanks for the reply,
I tried your solution and I got:
I dont really understand this result.
Add -s param to curl , and try to use without pretty
1 Like
Tomer you should use this solution:
curl -s localhost:9200/twitte/_search?filter_path=hits.total | tr -cd '[[:digit:]]'
dadoonet
(David Pilato)
March 26, 2017, 11:52am
8
Add size=0 to have better response time
1 Like
tomer
(tomer zaks)
March 26, 2017, 1:43pm
9
Thx, it does take sometime, where should I add this?
dadoonet
(David Pilato)
March 26, 2017, 3:18pm
10
curl -s "localhost:9200/twitter/_search?filter_path=hits.total&size=0" | tr -cd '[[:digit:]]'
2 Likes
system
(system)
Closed
April 23, 2017, 3:18pm
11
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.