# ES script code duplication

**URL:** <https://discuss.elastic.co/t/es-script-code-duplication/107567>\
**Category:** Elasticsearch\
**Created:** [November 14, 2017, 3:27pm UTC](https://discuss.elastic.co/t/es-script-code-duplication/107567 "2017-11-14T15:27:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![samatha\_kankipati](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@samatha\_kankipati](https://discuss.elastic.co/u/samatha_kankipati)\
**Post date:** [November 14, 2017, 3:27pm UTC](https://discuss.elastic.co/t/es-script-code-duplication/107567/1 "2017-11-14T15:27:59Z")

</div>

We have two scripts with almost same code.  
Is there any way we can remove code duplication between the scripts?  
Like including / calling one script from other?

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [November 15, 2017, 7:17am UTC](https://discuss.elastic.co/t/es-script-code-duplication/107567/2 "2017-11-15T07:17:01Z")

</div>

There is no way to call one script from another. But you could parameterize the script with the pieces that are different and pass those in via params?

---

<div class="post-metadata">

**Author:** ![samatha\_kankipati](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@samatha\_kankipati](https://discuss.elastic.co/u/samatha_kankipati)\
**Post date:** [November 15, 2017, 3:23pm UTC](https://discuss.elastic.co/t/es-script-code-duplication/107567/3 "2017-11-15T15:23:51Z")

</div>

Thanks @rjernst

---

<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:** [December 13, 2017, 3:24pm UTC](https://discuss.elastic.co/t/es-script-code-duplication/107567/4 "2017-12-13T15:24:14Z")

</div>

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