I'm trying to limit my Java API-run Elasticsearch queries so that they only return some specific fields from _source
.
The analogous query using the REST API looks like:
curl -X GET http://localhost:9200/ci_person/t/_search?q=name_s:ben&_source=name_s
How do I do this in Java?
searchRequestBuilder.addFields(<array of fields>);
only returns set fields, but in doing so it completely changes the structure of the returned data (replacing _source
with a nested field
object). This isn't acceptable for what I'm doing, because specifying a set of fields to return shouldn't completely change what's returned.