Reputation: 183
I am trying get the count of the log messages from elasticsearch which were logged by a pod, in a particular time-frame, using the count API. The below request does not return correct count. The count returned by this API, does not match with 'hits' count displayed on kibana for the same query and filter. Is there anything I am missing in the request.
GET /index_name/_count
"query": {
"bool": {
"must": [],
"filter": [{
"match_all": {}
}, {
"match_phrase": {
"kubernetes.pod_name": {
"query": "alpine-with-tags-info-2"
}
}
}, {
"range": {
"@timestamp": {
"format": "strict_date_optional_time",
"gte": "2020-06-15T10:45:00.000Z",
"lte": "2020-06-15T11:50:00.000Z"
}
}
}],
"should": [],
"must_not": []
}
}
}```
Upvotes: 1
Views: 944
Reputation: 16925
Are you sure it's not due to the breaking change in 7.0 regarding the total hits number?
You can force the count to always be accurate by setting
track_total_hits
totrue
explicitly in the search request.
Upvotes: 0