# How can we clear searchSource.aggs

**URL:** <https://discuss.elastic.co/t/how-can-we-clear-searchsource-aggs/125866>\
**Category:** Kibana\
**Created:** [March 28, 2018, 6:28am UTC](https://discuss.elastic.co/t/how-can-we-clear-searchsource-aggs/125866 "2018-03-28T06:28:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![whoami](https://avatars.discourse-cdn.com/v4/letter/w/a9a28c/32.png) [@whoami](https://discuss.elastic.co/u/whoami)\
**Post date:** [March 28, 2018, 6:28am UTC](https://discuss.elastic.co/t/how-can-we-clear-searchsource-aggs/125866/1 "2018-03-28T06:28:40Z")

</div>

as we know, if we wanna add agg param, we can use searchSource.aggs(xxx), but how can we clear the aggs params, any interface?

---

<div class="post-metadata">

**Author:** ![timroes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timroes/32/19712_2.png) [@timroes](https://discuss.elastic.co/u/timroes)\
**Post date:** [March 28, 2018, 5:28pm UTC](https://discuss.elastic.co/t/how-can-we-clear-searchsource-aggs/125866/2 "2018-03-28T17:28:27Z")

</div>

You can clear the aggs param (or any other), by just passing `null` to the method: `searchSource.aggs(null)`.

Cheers,  
Tim

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 25, 2018, 5:28pm UTC](https://discuss.elastic.co/t/how-can-we-clear-searchsource-aggs/125866/3 "2018-04-25T17:28:43Z")

</div>

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