# ES return more hits than I expected

**URL:** <https://discuss.elastic.co/t/es-return-more-hits-than-i-expected/71870>\
**Category:** Elasticsearch\
**Created:** [January 17, 2017, 3:04pm UTC](https://discuss.elastic.co/t/es-return-more-hits-than-i-expected/71870 "2017-01-17T15:04:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ji\_luo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ji_luo/32/14647_2.png) [@ji\_luo](https://discuss.elastic.co/u/ji_luo)\
**Post date:** [January 17, 2017, 3:04pm UTC](https://discuss.elastic.co/t/es-return-more-hits-than-i-expected/71870/1 "2017-01-17T15:04:38Z")

</div>

ES version: 2.4.2

I use transport client to sent a search request to an ES index which has 5 shards, request parameter: from=0, size=10. And then, I got 50 hits back (10 hits per shard, I think). But if I changed `from` parameter to something greater than 0, then I got only 10 hits back (that's what I expect).

I didn't find any explanation on this behavior.

So, any documents here?

---

<div class="post-metadata">

**Author:** ![JKhondhu](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@JKhondhu](https://discuss.elastic.co/u/JKhondhu)\
**Post date:** [January 17, 2017, 4:05pm UTC](https://discuss.elastic.co/t/es-return-more-hits-than-i-expected/71870/2 "2017-01-17T16:05:34Z")

</div>

This sounds like Pagination. Be it 10 results from the 5 shards. Can you share more on the exact search you are running and what you wanting to achieve.

---

<div class="post-metadata">

**Author:** ![ji\_luo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ji_luo/32/14647_2.png) [@ji\_luo](https://discuss.elastic.co/u/ji_luo)\
**Post date:** [January 17, 2017, 4:50pm UTC](https://discuss.elastic.co/t/es-return-more-hits-than-i-expected/71870/3 "2017-01-17T16:50:57Z")

</div>

@JKhondhu  
I pasted my request below, and I use java transport client to send request

```auto
{
  "from" : 0,
  "size" : 10,
  "query" : {
    "bool" : {
      "must" : {
        "query_string" : {
          "query" : "abcd",
          "fields" : ["description^1.0", "content^3.0", "title^6.0", "url_token^3.0"],
          "analyzer" : "keyword",
          "boost" : 2.0
        }
      }
    }
  }
}

```

What I want to achieve is that if I search with `from=0` and `size=10`, then I should get only 10 hits, not 50 hits. And I'm sure it's something about shard. I tried to change index shard num to 3, then I got 30 hits.

---

<div class="post-metadata">

**Author:** ![JKhondhu](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@JKhondhu](https://discuss.elastic.co/u/JKhondhu)\
**Post date:** [January 18, 2017, 2:20pm UTC](https://discuss.elastic.co/t/es-return-more-hits-than-i-expected/71870/4 "2017-01-18T14:20:03Z")

</div>

@ji_luo What are you hoping to achieve here? You mention the transport client. Is this a one time query to get the top ten? (example) Top ten movies with the fields you have provided?

What will your application be doing with the queried data?

---

<div class="post-metadata">

**Author:** ![ji\_luo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ji_luo/32/14647_2.png) [@ji\_luo](https://discuss.elastic.co/u/ji_luo)\
**Post date:** [January 18, 2017, 5:21pm UTC](https://discuss.elastic.co/t/es-return-more-hits-than-i-expected/71870/5 "2017-01-18T17:21:50Z")

</div>

@JKhondhu

I solved the problem.

In case other people may encounter the same problem, I will write down the reason here.

The problem is caused by different search types, if I use default search type `query_then_fetch`, the returned hit count is as I expected, but if I use `query_and_fetch`, it will return `num_of_shards * size` hits, more than I want, it adds more burden on network, and increases response time.

---

<div class="post-metadata">

**Author:** ![JKhondhu](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@JKhondhu](https://discuss.elastic.co/u/JKhondhu)\
**Post date:** [January 18, 2017, 9:49pm UTC](https://discuss.elastic.co/t/es-return-more-hits-than-i-expected/71870/6 "2017-01-18T21:49:21Z")

</div>

Good to hear @ji_luo

---

<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:** [February 15, 2017, 9:50pm UTC](https://discuss.elastic.co/t/es-return-more-hits-than-i-expected/71870/7 "2017-02-15T21:50:01Z")

</div>

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