We are using searchSourceBuilder to create queries. We have source enabled in our mapping and we've tried setting the searchSourceBuilder.fetchSource(false) in our client code. It works fine for normal search requests. However, when we give an aggregation query, the _source is returned.
We have code something like below :
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); searchSourceBuilder.query(query) // query is already built searchSourceBuilder.aggregation(agg) // agg is also built seperately. searchSourceBuilder.fetchSource(false) SearchRequest searchRequest = new SearchRequest(); client.search(searchRequest, RequestOptions.DEFAULT) //Our client is REST High Level Client
I'm not sure if this expected that aggregation would always return _source field or a bug.
Client Jar we are using is elasticsearch-6.6.0