# Bug in elasticsearch search\_after rest api?

**URL:** https://discuss.elastic.co/t/bug-in-elasticsearch-search-after-rest-api/240215
**Category:** Elasticsearch
**Created:** [July 7, 2020, 7:57pm UTC](https://discuss.elastic.co/t/bug-in-elasticsearch-search-after-rest-api/240215 "2020-07-07T19:57:46Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![corbosman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/corbosman/32/62787_2.png) [@corbosman](https://discuss.elastic.co/u/corbosman)
#### Post date: [July 7, 2020, 7:57pm UTC](https://discuss.elastic.co/t/bug-in-elasticsearch-search-after-rest-api/240215/1 "2020-07-07T19:57:46Z")

</div>

Hi all, im running into what I'm thinking might be a bug. I'm using the REST search api to return log entries stored in our elasticsearch cluster. This could run into the tens of thousands, so I'm using search\_after to return subsets at a time. This is mostly just working fine, but I ran into a small issue in the response. The last page returns this for hits.total even though the actual number of documents in that specific "paginated" response is well below 10.000.

```auto
{
  'value' => 10000,
   'relation' => 'gte'
};

```

Is this a bug? I was expecting the see the actual number of returned documents there and use it to stop the loop. This is latest ES7.8

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 8, 2020, 3:54am UTC](https://discuss.elastic.co/t/bug-in-elasticsearch-search-after-rest-api/240215/2 "2020-07-08T03:54:27Z")

</div>

This number shows the "total" number of hits whatever the "page" you're looking at.

So this is expected.

---

<div class="post-metadata">

### Author: ![corbosman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/corbosman/32/62787_2.png) [@corbosman](https://discuss.elastic.co/u/corbosman)
#### Post date: [July 8, 2020, 8:12am UTC](https://discuss.elastic.co/t/bug-in-elasticsearch-search-after-rest-api/240215/3 "2020-07-08T08:12:04Z")

</div>

So there is no way to see how many results you're getting back in your current query?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 8, 2020, 10:17pm UTC](https://discuss.elastic.co/t/bug-in-elasticsearch-search-after-rest-api/240215/4 "2020-07-08T22:17:17Z")

</div>

You mean? The number of hits on the current page or the exact total number of hits?

---

<div class="post-metadata">

### Author: ![corbosman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/corbosman/32/62787_2.png) [@corbosman](https://discuss.elastic.co/u/corbosman)
#### Post date: [July 8, 2020, 10:32pm UTC](https://discuss.elastic.co/t/bug-in-elasticsearch-search-after-rest-api/240215/5 "2020-07-08T22:32:19Z")

</div>

The number of hits on the current page, especially the last page. So lets say I have 45000 hits in total, page 1 to 4 have the maximum of 10000 hits, so I expect the last page to have 5000 hits. Is there a way to see that 5000 number anywhere as a response of that specific 5th query?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 9, 2020, 3:14am UTC](https://discuss.elastic.co/t/bug-in-elasticsearch-search-after-rest-api/240215/6 "2020-07-09T03:14:04Z")

</div>

No but you can count how many hits you have in the array in the response I guess?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [August 6, 2020, 3:14am UTC](https://discuss.elastic.co/t/bug-in-elasticsearch-search-after-rest-api/240215/7 "2020-08-06T03:14:12Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
