# How to read fields from hits?

**URL:** <https://discuss.elastic.co/t/how-to-read-fields-from-hits/6112>\
**Category:** Elasticsearch\
**Created:** [December 9, 2011, 8:10pm UTC](https://discuss.elastic.co/t/how-to-read-fields-from-hits/6112 "2011-12-09T20:10:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yuhan](https://avatars.discourse-cdn.com/v4/letter/y/919ad9/32.png) [@Yuhan](https://discuss.elastic.co/u/Yuhan)\
**Post date:** [December 9, 2011, 8:10pm UTC](https://discuss.elastic.co/t/how-to-read-fields-from-hits/6112/1 "2011-12-09T20:10:43Z")

</div>

HI all,

I'm trying to use java client to search and retrieve results from an  
elasticsearch server.  
so far, I'm able to search for hits and corresponding ids. but the  
fields associated with  
the search results are empty (but I only have the document id's from  
the hits).  
should I perform another "actionGet" into to get the document content?  
as an api reference, which  
test case talks about retrieve record?

[https://github.com/elasticsearch/elasticsearch/tree/master/src/test/](https://github.com/elasticsearch/elasticsearch/tree/master/src/test/)

thanks!

Yuhan  
[[Reference Code 102932]]

---

<div class="post-metadata">

**Author:** ![Yuhan](https://avatars.discourse-cdn.com/v4/letter/y/919ad9/32.png) [@Yuhan](https://discuss.elastic.co/u/Yuhan)\
**Post date:** [December 9, 2011, 8:19pm UTC](https://discuss.elastic.co/t/how-to-read-fields-from-hits/6112/2 "2011-12-09T20:19:00Z")

</div>

oh nvm. I just need to put .addField in the SearchRequestBuilder to  
find the fields. thanks!

Yuhan

On Dec 9, 12:10 pm, Yuhan [yzh...@onescreen.com](mailto:yzh...@onescreen.com) wrote:

> HI all,
> 
> I'm trying to use java client to search and retrieve results from an  
> elasticsearch server.  
> so far, I'm able to search for hits and corresponding ids. but the  
> fields associated with  
> the search results are empty (but I only have the document id's from  
> the hits).  
> should I perform another "actionGet" into to get the document content?  
> as an api reference, which  
> test case talks about retrieve record?
> 
> [https://github.com/elasticsearch/elasticsearch/tree/master/src/test/](https://github.com/elasticsearch/elasticsearch/tree/master/src/test/)
> 
> thanks!
> 
> Yuhan  
> [[Reference Code 102932]]  
> [[Reference Code 102932]]

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [December 9, 2011, 10:12pm UTC](https://discuss.elastic.co/t/how-to-read-fields-from-hits/6112/3 "2011-12-09T22:12:14Z")

</div>

Note that by default the full source document is returned when you search,  
so you can get it when asking for source on the hit. Note, once you ask for  
specific fields, \_source will not be returned by default anymore.

On Fri, Dec 9, 2011 at 10:19 PM, Yuhan [yzhang@onescreen.com](mailto:yzhang@onescreen.com) wrote:

> oh nvm. I just need to put .addField in the SearchRequestBuilder to  
> find the fields. thanks!
> 
> Yuhan
> 
> On Dec 9, 12:10 pm, Yuhan [yzh...@onescreen.com](mailto:yzh...@onescreen.com) wrote:
> 
> > HI all,
> > 
> > I'm trying to use java client to search and retrieve results from an  
> > elasticsearch server.  
> > so far, I'm able to search for hits and corresponding ids. but the  
> > fields associated with  
> > the search results are empty (but I only have the document id's from  
> > the hits).  
> > should I perform another "actionGet" into to get the document content?  
> > as an api reference, which  
> > test case talks about retrieve record?
> > 
> > [https://github.com/elasticsearch/elasticsearch/tree/master/src/test/](https://github.com/elasticsearch/elasticsearch/tree/master/src/test/)
> > 
> > thanks!
> > 
> > Yuhan  
> > [[Reference Code 102932]]  
> > [[Reference Code 102932]]

---

<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:45am UTC](https://discuss.elastic.co/t/how-to-read-fields-from-hits/6112/4 "2017-07-06T03:45:53Z")

</div>


