I have a SearchSourceBuilder which has all blocks like Query,From, Size, Aggregations etc. But later I want to remove only the Aggregations blocks for some use case fully before sending the DSL to ES.
Example, I need to remove the entire aggregations block from the SearchSourceBuilder from the entire DSL

SearchSourceBuilderclass has multipleaggregationmethods to build different types of aggregations as shown in the intelliJ image belowYou just need to remove those aggregation method from SearchSourceBuilder
For example, my below code uses
query filters,sizeandagssAnd if I don't want
aggs, I can just use below code