# How does elasticsearch know the document id?

**URL:** <https://discuss.elastic.co/t/how-does-elasticsearch-know-the-document-id/57110>\
**Category:** Elasticsearch\
**Created:** [August 3, 2016, 1:45pm UTC](https://discuss.elastic.co/t/how-does-elasticsearch-know-the-document-id/57110 "2016-08-03T13:45:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [August 3, 2016, 1:45pm UTC](https://discuss.elastic.co/t/how-does-elasticsearch-know-the-document-id/57110/1 "2016-08-03T13:45:10Z")

</div>

Hi!

I would like to ask question related to document routing.

According to definitive guide, elasticsearch uses **document id** to retrieve a document.

[https://www.elastic.co/guide/en/elasticsearch/guide/2.x/routing-value.html](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/routing-value.html)

However, when queries such as term and match queries are used, document id are not specified in the query.  
In this case, how does elasticsearch find out the document id and route to correct shard?

Thanks,  
Yu Watanabe

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [August 3, 2016, 1:50pm UTC](https://discuss.elastic.co/t/how-does-elasticsearch-know-the-document-id/57110/2 "2016-08-03T13:50:42Z")

</div>

Hi,  
thats easy, queries go to all shards. The whole point of searching is to find the ids of documents that are matching the query, possibly also scoring and ranking them.

---

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [August 3, 2016, 2:04pm UTC](https://discuss.elastic.co/t/how-does-elasticsearch-know-the-document-id/57110/3 "2016-08-03T14:04:11Z")

</div>

Hi @cbuescher

Ah . Your talking about this.

[https://www.elastic.co/guide/en/elasticsearch/guide/2.x/distributed-search.html](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/distributed-search.html)

I will look into it . Thank you.

---

<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:30pm UTC](https://discuss.elastic.co/t/how-does-elasticsearch-know-the-document-id/57110/4 "2017-07-05T22:30:24Z")

</div>


