# ExecutableScript life cycle - initialize and dispose

**URL:** <https://discuss.elastic.co/t/executablescript-life-cycle-initialize-and-dispose/10449>\
**Category:** Elasticsearch\
**Created:** [January 22, 2013, 10:49am UTC](https://discuss.elastic.co/t/executablescript-life-cycle-initialize-and-dispose/10449 "2013-01-22T10:49:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Didde\_Brockman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/didde_brockman/32/2525_2.png) [@Didde\_Brockman](https://discuss.elastic.co/u/Didde_Brockman)\
**Post date:** [January 22, 2013, 10:49am UTC](https://discuss.elastic.co/t/executablescript-life-cycle-initialize-and-dispose/10449/1 "2013-01-22T10:49:20Z")

</div>

Hi guys,

While working with a custom native scorer, we identified the need to run  
code upon search completion. We would basically have a life cycle where we  
can detect (read: run code) on search start and search end in order to  
initialize and finalize/dispose some internal data structures.

Looking at the docs, I cannot seem to find anything indicating such  
features have been implemented. We are using AbstractLongSearchScript at  
the moment, but are open for change if you guys can point us in another  
direction allowing for more of a life cycle-ish approach within a plugin.

The javadocs are slightly bare when it comes to ExecutableScript and its  
relatives.

Thanks for your time.

--

---

<div class="post-metadata">

**Author:** ![Mohammady\_Mahdy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohammady_mahdy/32/2128_2.png) [@Mohammady\_Mahdy](https://discuss.elastic.co/u/Mohammady_Mahdy)\
**Post date:** [February 5, 2013, 8:26am UTC](https://discuss.elastic.co/t/executablescript-life-cycle-initialize-and-dispose/10449/2 "2013-02-05T08:26:18Z")

</div>

Any luck on this? if you have a solution post it please.

On Tuesday, January 22, 2013 2:49:20 PM UTC+4, Didde Brockman wrote:

> Hi guys,
> 
> While working with a custom native scorer, we identified the need to run  
> code upon search completion. We would basically have a life cycle where we  
> can detect (read: run code) on search start and search end in order to  
> initialize and finalize/dispose some internal data structures.
> 
> Looking at the docs, I cannot seem to find anything indicating such  
> features have been implemented. We are using AbstractLongSearchScript at  
> the moment, but are open for change if you guys can point us in another  
> direction allowing for more of a life cycle-ish approach within a plugin.
> 
> The javadocs are slightly bare when it comes to ExecutableScript and its  
> relatives.
> 
> Thanks for your time.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:53am UTC](https://discuss.elastic.co/t/executablescript-life-cycle-initialize-and-dispose/10449/3 "2017-07-06T02:53:02Z")

</div>

Closed on July 6, 2017, 2:53am UTC


