# How to get elasticsearch document id against topdocs.scandocs\[i\].doc

**URL:** <https://discuss.elastic.co/t/how-to-get-elasticsearch-document-id-against-topdocs-scandocs-i-doc/129040>\
**Category:** Elasticsearch\
**Created:** [April 23, 2018, 6:32am UTC](https://discuss.elastic.co/t/how-to-get-elasticsearch-document-id-against-topdocs-scandocs-i-doc/129040 "2018-04-23T06:32:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![maarab](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@maarab](https://discuss.elastic.co/u/maarab)\
**Post date:** [April 23, 2018, 6:32am UTC](https://discuss.elastic.co/t/how-to-get-elasticsearch-document-id-against-topdocs-scandocs-i-doc/129040/1 "2018-04-23T06:32:47Z")

</div>

In my elasticsearch plugin code I get the results in topdocs. While looping through topdocs, there is an id that is retrieved by doing topdocs.scandocs[i].doc. This id is not the elasticsearch document id. How can I get the elasticsearch document id so that I can compare if what is returned in topdocs is really the result that is return by the elasticsearch query?

---

<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:** [May 21, 2018, 6:39am UTC](https://discuss.elastic.co/t/how-to-get-elasticsearch-document-id-against-topdocs-scandocs-i-doc/129040/2 "2018-05-21T06:39:12Z")

</div>

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