in dsl I use _source: [] to define what fields I want returned in the response:
{
"size":100,
"_source": [ "field1", "field2", "field3", "field4" ]
}
but I am having trouble figuring this out with the Java API Transport Client. Below is what I use to construct and call the query, so I am not sure what to use for this.
SearchResponse sr = mysvc.getClient().prepareSearch(index)
.setSize(size)
.setQuery(getBoolQuery())
.addAggregation(getAggregationBuilder())
.execute()
.actionGet()
there is a .setSource()
that can be used here but it takes a SearchSourceBuilder and I haven't any documentation on how to use it.
Maybe this would be helpful for you: