Ok. I see now. Thanks for the clarification.
I'm afraid you have to build yourself your entity using getters/setters for all individual fields or to create a new JSON with your fields and use Jackson.
One more comment, you can also ask for field _source in requestBuilder.add().
--
David
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
Le 12 mars 2013 à 08:18, Mihai Cazacu cazacugmihai@gmail.com a écrit :
Yes, I looked at that link but it is not related to my question.
I have a SearchResponse as a response for a query that request only some fields from the object (I mentioned in my initial post the link to the query type Elasticsearch Platform — Find real-time answers at scale | Elastic):
SearchRequestBuilder requestBuilder = client.prepareSearch....
requestBuilder.addFields("field1", "field5.subField2", "field7")
Now, I want to build my objects from the response.
SearchHits hitsInfo = response.getHits()
SearchHit hits = hitsInfo.hits()
for (SearchHit hit : hits) {
// here, hit.getSourceAsString() returns null
Map<String, SearchHitField> fields = hit.fields()
MyFullObject obj = decodeMyFullObject(hit)
}
So, my MyFullObject must be populated with that fields (that represent a part of all MyFullObject fields) returned by the response.
Thanks,
Mihai
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.