searchSourceBuilder fetchSource flag doesn't work for aggregation responses


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.
SearchRequest searchRequest = new 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


This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.