How to read fields from hits?


(Yuhan) #1

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/

thanks!

Yuhan
[[Reference Code 102932]]


(Yuhan) #2

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 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/

thanks!

Yuhan
[[Reference Code 102932]]
[[Reference Code 102932]]


(Shay Banon) #3

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 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 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/

thanks!

Yuhan
[[Reference Code 102932]]
[[Reference Code 102932]]


(system) #4