# ElasticSearch returning less results even with set Size = 50

**URL:** <https://discuss.elastic.co/t/elasticsearch-returning-less-results-even-with-set-size-50/74021>\
**Category:** Elasticsearch\
**Created:** [February 6, 2017, 8:21am UTC](https://discuss.elastic.co/t/elasticsearch-returning-less-results-even-with-set-size-50/74021 "2017-02-06T08:21:21Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mv\_es](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@mv\_es](https://discuss.elastic.co/u/mv_es)\
**Post date:** [February 6, 2017, 8:21am UTC](https://discuss.elastic.co/t/elasticsearch-returning-less-results-even-with-set-size-50/74021/1 "2017-02-06T08:21:21Z")

</div>

On running my ES query, total **hits received are shown to be 7746**  
Yet, setting the size param to 50, the **query is returning only 46 results**.  
What could be the reason for ES not returning the last 4 results?

The top score is 1.17, while that of the 46th result is 0.17.  
On setting the size to 70, the lowest ranking record has score 0.15. Thus score of the 50th record must be between the two value.

Does ES maintain a threshold of sorts, based on the top score? Below which results are not returned despite the size?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [February 6, 2017, 9:05am UTC](https://discuss.elastic.co/t/elasticsearch-returning-less-results-even-with-set-size-50/74021/2 "2017-02-06T09:05:20Z")

</div>

> [@mv\_es](#):
>
> Does ES maintain a threshold of sorts, based on the top score? Below which results are not returned despite the size?

No. I think we'll need to see more details about your specific query/data/mapping to debug further.

---

<div class="post-metadata">

**Author:** ![amar-tari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amar-tari/32/14243_2.png) [@amar-tari](https://discuss.elastic.co/u/amar-tari)\
**Post date:** [February 6, 2017, 9:31am UTC](https://discuss.elastic.co/t/elasticsearch-returning-less-results-even-with-set-size-50/74021/3 "2017-02-06T09:31:14Z")

</div>

Can you please post your query ?

---

<div class="post-metadata">

**Author:** ![mv\_es](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@mv\_es](https://discuss.elastic.co/u/mv_es)\
**Post date:** [February 6, 2017, 9:35am UTC](https://discuss.elastic.co/t/elasticsearch-returning-less-results-even-with-set-size-50/74021/4 "2017-02-06T09:35:10Z")

</div>

Hi,

Thanks for the prompt response.  
The index contains documents, total size being: 1.9gb, no. of docs ~ 0.5 million  
**This is what the index mapping looks like:**

"mapping\_cluster" : {  
"mappings" : {  
"articles" : {  
"properties" : {  
"alexaRank" : {  
"type" : "long"  
},  
"content" : {  
"type" : "string"  
},  
"description" : {  
"type" : "string"  
},  
"imageURL" : {  
"type" : "string"  
},  
"pubDate" : {  
"type" : "date",  
"format" : "strict\_date\_optional\_time||epoch\_millis"  
},  
"sourceName" : {  
"type" : "string"  
},  
"title" : {  
"type" : "string"  
},  
"url" : {  
"type" : "string"  
}  
}  
}  
}  
}

**And the query is as follows:**  
curl -XPOST 'localhost:9200/search\_cluster/\_search?pretty&size=50' -d'  
{ "query": {  
"function\_score" : {  
"query" : {  
"multi\_match" : {  
"query" : "Chicago",  
"fields" : ["title", "url", "content^3"],  
"type" : "phrase",  
"slop" : 10,  
"tie\_breaker" : 0.3  
}  
},  
"functions" : [ {  
"gauss" : {  
"pubDate" : {  
"scale" : "8h",  
"decay" : 0.7  
}  
}  
} ],  
"score\_mode" : "multiply"  
}  
}}'

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [February 6, 2017, 9:48am UTC](https://discuss.elastic.co/t/elasticsearch-returning-less-results-even-with-set-size-50/74021/5 "2017-02-06T09:48:57Z")

</div>

I expect the function\_score is the culprit here - if vanilla ranking was broken in the way you described we'd certainly know about it.  
What version of elasticsearch are you using here?  
In the interests of getting down to the smallest reproducible example we can test do you see this issue if you replace the multi\_match with a `match_all` query?

---

<div class="post-metadata">

**Author:** ![mv\_es](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@mv\_es](https://discuss.elastic.co/u/mv_es)\
**Post date:** [February 6, 2017, 10:27am UTC](https://discuss.elastic.co/t/elasticsearch-returning-less-results-even-with-set-size-50/74021/6 "2017-02-06T10:27:50Z")

</div>

Hey,

ES version: 2.3.4  
Having the same issue with match\_all query as well. getting 35-36 docs only.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [February 6, 2017, 10:47am UTC](https://discuss.elastic.co/t/elasticsearch-returning-less-results-even-with-set-size-50/74021/7 "2017-02-06T10:47:49Z")

</div>

> [@mv\_es](#):
>
> Having the same issue with match\_all query as well. getting 35-36 docs only.

That helps narrow things down. Any chance you can supply the date values for the docs in your problem set?

---

<div class="post-metadata">

**Author:** ![mv\_es](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@mv\_es](https://discuss.elastic.co/u/mv_es)\
**Post date:** [February 6, 2017, 1:51pm UTC](https://discuss.elastic.co/t/elasticsearch-returning-less-results-even-with-set-size-50/74021/8 "2017-02-06T13:51:54Z")

</div>

I realised later that their was some kind of filtering happening in the system, at a later stage, which i had missed initially. The number of articles being returned right after the query was executed were correct.  
Sorry for the trouble.  
Thank you for all the help!

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [February 6, 2017, 1:58pm UTC](https://discuss.elastic.co/t/elasticsearch-returning-less-results-even-with-set-size-50/74021/9 "2017-02-06T13:58:26Z")

</div>

...you had us worried here. We've released the author of `function_score` from the interrogation room and he has agreed not to press any charges.

All good.

---

<div class="post-metadata">

**Author:** ![mv\_es](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@mv\_es](https://discuss.elastic.co/u/mv_es)\
**Post date:** [February 6, 2017, 1:59pm UTC](https://discuss.elastic.co/t/elasticsearch-returning-less-results-even-with-set-size-50/74021/10 "2017-02-06T13:59:29Z")

</div>

Haha!  
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:** [March 6, 2017, 1:59pm UTC](https://discuss.elastic.co/t/elasticsearch-returning-less-results-even-with-set-size-50/74021/11 "2017-03-06T13:59:39Z")

</div>

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