# About the retrieval depth & ranking

**URL:** <https://discuss.elastic.co/t/about-the-retrieval-depth-ranking/51945>\
**Category:** Elasticsearch\
**Created:** [June 6, 2016, 12:32pm UTC](https://discuss.elastic.co/t/about-the-retrieval-depth-ranking/51945 "2016-06-06T12:32:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanzhiyuan](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sanzhiyuan](https://discuss.elastic.co/u/sanzhiyuan)\
**Post date:** [June 6, 2016, 12:32pm UTC](https://discuss.elastic.co/t/about-the-retrieval-depth-ranking/51945/1 "2016-06-06T12:32:31Z")

</div>

Hi all,  
I have 2 questions about retrieval and scoring,

1. How deep when ES retrieving documents, even without scoring? By now the information I got was all. please help me to ensure this mechanism. Actually when I was developing a web search engine, normally the retriever would interrupt when it thinks there are "enough good" candidate documents for this search, likely, just top10 in 10,000 docs.

2. The search result ranking for one same query on one static index, stable or not? For most times it is stable, but sometimes ES returns different results, I was guessing this is caused by some bad shards, but not sure. Any help?

Thanks all ^.^

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 6, 2016, 11:01pm UTC](https://discuss.elastic.co/t/about-the-retrieval-depth-ranking/51945/2 "2016-06-06T23:01:58Z")

</div>

[https://www.elastic.co/guide/en/elasticsearch/guide/current/distributed-search.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/distributed-search.html) may help clarify this.

---

<div class="post-metadata">

**Author:** ![sanzhiyuan](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sanzhiyuan](https://discuss.elastic.co/u/sanzhiyuan)\
**Post date:** [June 7, 2016, 2:47am UTC](https://discuss.elastic.co/t/about-the-retrieval-depth-ranking/51945/3 "2016-06-07T02:47:15Z")

</div>

Thanks mark:) ,  
The chapter explains how "dispatcher & gatherer" works, but I want to know when the gatherer knows its own private priority queue is fulfilled. (I guess, It can't just retrieve exactly from+size docs, the pagination can't be stable if so, and also it seems doesn't retrieve all docs since the book says "deep paging is a problem" - sorting won't be a problem when you retrieved all docs, I think) [https://www.elastic.co/guide/en/elasticsearch/guide/current/pagination.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/pagination.html)

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 7, 2016, 2:51am UTC](https://discuss.elastic.co/t/about-the-retrieval-depth-ranking/51945/4 "2016-06-07T02:51:27Z")

</div>

It just grabs the number of docs (default 10) from each shard.

So if you have 5 shards, each provides the top 10, then the reduce phase takes that total of 50 and provides the top 10 from that.

---

<div class="post-metadata">

**Author:** ![sanzhiyuan](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sanzhiyuan](https://discuss.elastic.co/u/sanzhiyuan)\
**Post date:** [June 7, 2016, 3:03am UTC](https://discuss.elastic.co/t/about-the-retrieval-depth-ranking/51945/5 "2016-06-07T03:03:08Z")

</div>

Yes I understand that part, I'd like to know how a shard chooses its top10 result, I mean, the progress of building this priority queue(from + size, 10 by default)

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 7, 2016, 3:51am UTC](https://discuss.elastic.co/t/about-the-retrieval-depth-ranking/51945/6 "2016-06-07T03:51:34Z")

</div>

Ah right, sorry! So that's this part - [https://www.elastic.co/guide/en/elasticsearch/guide/current/sorting.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/sorting.html)

Basically it scores anything that matches the query/filter.

---

<div class="post-metadata">

**Author:** ![sanzhiyuan](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sanzhiyuan](https://discuss.elastic.co/u/sanzhiyuan)\
**Post date:** [June 7, 2016, 3:58am UTC](https://discuss.elastic.co/t/about-the-retrieval-depth-ranking/51945/7 "2016-06-07T03:58:45Z")

</div>

Thanks! this helps me a lot 🙂

---

<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 5, 2017, 10:45pm UTC](https://discuss.elastic.co/t/about-the-retrieval-depth-ranking/51945/8 "2017-07-05T22:45:48Z")

</div>


