# Bucket Scripting

**URL:** <https://discuss.elastic.co/t/bucket-scripting/99596>\
**Category:** Elasticsearch\
**Created:** [September 6, 2017, 2:18pm UTC](https://discuss.elastic.co/t/bucket-scripting/99596 "2017-09-06T14:18:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tirthankar\_Sarkar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tirthankar_sarkar/32/19725_2.png) [@Tirthankar\_Sarkar](https://discuss.elastic.co/u/Tirthankar_Sarkar)\
**Post date:** [September 6, 2017, 2:18pm UTC](https://discuss.elastic.co/t/bucket-scripting/99596/1 "2017-09-06T14:18:26Z")

</div>

How does ES bucket scripting work internally?  
Is it scalable to add multiple bucket scripts into the same aggregations ...

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [September 6, 2017, 2:56pm UTC](https://discuss.elastic.co/t/bucket-scripting/99596/2 "2017-09-06T14:56:24Z")

</div>

If you are talking about the [`bucket_script` aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/search-aggregations-pipeline-bucket-script-aggregation.html) then you can indeed add multiple `bucket_script` aggregations with the same parent aggregation. The `bucket_script` aggregations will be run sequentially after any non-pipeline aggregations have be processed in the reduce phase on the coordinating node. This means that each `bucket_script` you run will add time to the total time taken to complete the search request. We recommend that the scripts used in the `bucket_script` are relatively simple.

---

<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:** [October 4, 2017, 2:56pm UTC](https://discuss.elastic.co/t/bucket-scripting/99596/3 "2017-10-04T14:56:37Z")

</div>

Closed on October 4, 2017, 2:56pm UTC

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