# ElasticSearch Query string returns total hits different than scroll

**URL:** https://discuss.elastic.co/t/elasticsearch-query-string-returns-total-hits-different-than-scroll/275462
**Category:** Elasticsearch
**Created:** [June 9, 2021, 3:22pm UTC](https://discuss.elastic.co/t/elasticsearch-query-string-returns-total-hits-different-than-scroll/275462 "2021-06-09T15:22:01Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![telebh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/telebh/32/42272_2.png) [@telebh](https://discuss.elastic.co/u/telebh)
#### Post date: [June 9, 2021, 3:22pm UTC](https://discuss.elastic.co/t/elasticsearch-query-string-returns-total-hits-different-than-scroll/275462/1 "2021-06-09T15:22:02Z")

</div>

Hi There,  
I run query string against new ES V7 which expected to return 25k result set, but only returns total hit 1000, when running the same query but using scroll, it returns the expected correct count of 25k as a total hit. Please find the following output. It used to work fine in ES V6. How can I get total 25k hits for regular query\_string search (without scroll)?

```auto
GET author/_search
{
  "query": {
    "query_string": {
      "default_field": "audoc.authlast",
      "query": "audoc.authlast:smith"
    }
  }
}

```

----- result

` "hits" : { "total" : { "value" : 10000, "relation" : "gte" }`

`GET author/_search?scroll=2m { "size": 10000, "stored_fields": ["audoc.auid"], "query": { "query_string": { "default_field": "audoc.authlast", "query": "audoc.authlast:smith" } } }`

------ result  
`"hits" : { "total" : { "value" : 25983, "relation" : "eq" }`

---

<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: [June 9, 2021, 3:58pm UTC](https://discuss.elastic.co/t/elasticsearch-query-string-returns-total-hits-different-than-scroll/275462/2 "2021-06-09T15:58:28Z")

</div>

Run this:

```auto
GET author/_search
{
  "track_total_hits": true,
  "query": {
    "query_string": {
      "default_field": "audoc.authlast",
      "query": "audoc.authlast:smith"
    }
  }
}

```

See

> **[Search your data | Elasticsearch Guide \[7.13\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-your-data.html#track-total-hits)**

---

<div class="post-metadata">

### Author: ![telebh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/telebh/32/42272_2.png) [@telebh](https://discuss.elastic.co/u/telebh)
#### Post date: [June 9, 2021, 5:01pm UTC](https://discuss.elastic.co/t/elasticsearch-query-string-returns-total-hits-different-than-scroll/275462/3 "2021-06-09T17:01:11Z")

</div>

Great! I have tried adding the new attribute "track\_total\_hits:true" and that worked! thanks

---

<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: [July 7, 2021, 5:01pm UTC](https://discuss.elastic.co/t/elasticsearch-query-string-returns-total-hits-different-than-scroll/275462/4 "2021-07-07T17:01:19Z")

</div>

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