# Not getting \_id when searching with Java API

**URL:** <https://discuss.elastic.co/t/not-getting--id-when-searching-with-java-api/4988>\
**Category:** Elasticsearch\
**Created:** [July 28, 2011, 3:26pm UTC](https://discuss.elastic.co/t/not-getting--id-when-searching-with-java-api/4988 "2011-07-28T15:26:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrej](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Andrej](https://discuss.elastic.co/u/Andrej)\
**Post date:** [July 28, 2011, 3:26pm UTC](https://discuss.elastic.co/t/not-getting--id-when-searching-with-java-api/4988/1 "2011-07-28T15:26:42Z")

</div>

Hello,

I have the following problem: I am searching an index using the Java API. Everything works fine, except I am not getting back the \_id of the search hits. I tried to insert \_id into the fields, I also tried an empty field (as I understand in this case \_id should be returned by default). Neither works for me. What is the proper way to return the id of serach hits in Java?

Thanks!  
Andrej

---

<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 6, 2017, 3:58am UTC](https://discuss.elastic.co/t/not-getting--id-when-searching-with-java-api/4988/2 "2017-07-06T03:58:56Z")

</div>


