# Elasticsearch 2.0 scripted\_metric retrieve other script

**URL:** <https://discuss.elastic.co/t/elasticsearch-2-0-scripted-metric-retrieve-other-script/45800>\
**Category:** Elasticsearch\
**Created:** [March 30, 2016, 1:36pm UTC](https://discuss.elastic.co/t/elasticsearch-2-0-scripted-metric-retrieve-other-script/45800 "2016-03-30T13:36:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thanh\_Hai\_Ngo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thanh_hai_ngo/32/8769_2.png) [@Thanh\_Hai\_Ngo](https://discuss.elastic.co/u/Thanh_Hai_Ngo)\
**Post date:** [March 30, 2016, 1:36pm UTC](https://discuss.elastic.co/t/elasticsearch-2-0-scripted-metric-retrieve-other-script/45800/1 "2016-03-30T13:36:15Z")

</div>

I have a plugin with some native scripts. Successfully install to ES 2.0:

`module.registerScript("test-script", TestScript.Factory.class);`

Is there any way to get this script inside another groovy script. Previously I used facets to get that script from script context. But ES 2.0 stop supporting facets.

Example: I want to get "test-script" inside "init\_script" of aggregation

```
POST indext/_search
{
    "query": {"match_all": {}},
    "aggregations" : {
       "test" : {
           "scripted_metric" : {
           "init_script" : "* script = new TestScript() OR scriptService = _ctx.scriptService(); script = scriptService.compile('native','test-script', null); //worked with facet; script.run(params);",
           "map_script" : "test-script"
         }
      }
   }
}
```

---

<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 5, 2017, 11:04pm UTC](https://discuss.elastic.co/t/elasticsearch-2-0-scripted-metric-retrieve-other-script/45800/2 "2017-07-05T23:04:04Z")

</div>


