# Script\_score: the script could not be loaded

**URL:** <https://discuss.elastic.co/t/script-score-the-script-could-not-be-loaded/105816>\
**Category:** Elasticsearch\
**Created:** [October 30, 2017, 10:31pm UTC](https://discuss.elastic.co/t/script-score-the-script-could-not-be-loaded/105816 "2017-10-30T22:31:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srinivasan\_Ramaswamy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/srinivasan_ramaswamy/32/74106_2.png) [@Srinivasan\_Ramaswamy](https://discuss.elastic.co/u/Srinivasan_Ramaswamy)\
**Post date:** [October 30, 2017, 10:31pm UTC](https://discuss.elastic.co/t/script-score-the-script-could-not-be-loaded/105816/1 "2017-10-30T22:31:51Z")

</div>

I am trying to write a custom scoring plugin (for elasticsearch 5.6.2.) by following the example mentioned here

[https://www.elastic.co/guide/en/elasticsearch/reference/5.6/modules-scripting-engine.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/modules-scripting-engine.html)

I packaged my plugin using maven and installed it in elasticsearch. When i start elasticsearch, i see the message "my\_plugin" loaded.

But when i issue a query similar to the one mentioned in the above url, I get the following error message

```
org.elasticsearch.transport.RemoteTransportException: [9410gLh][127.0.0.1:9300][indices:data/read/search[phase/query]]
Caused by: org.elasticsearch.index.query.QueryShardException: script_score: the script could not be loaded
	at org.elasticsearch.index.query.functionscore.ScriptScoreFunctionBuilder.doToFunction(ScriptScoreFunctionBuilder.java:100) ~[elasticsearch-5.6.2.jar:5.6.2]
	at org.elasticsearch.index.query.functionscore.ScoreFunctionBuilder.toFunction(ScoreFunctionBuilder.java:137) ~[elasticsearch-5.6.2.jar:5.6.2]
	at org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder.doToQuery(FunctionScoreQueryBuilder.java:304) ~[elasticsearch-5.6.2.jar:5.6.2]
	at org.elasticsearch.index.query.AbstractQueryBuilder.toQuery(AbstractQueryBuilder.java:96) ~[elasticsearch-5.6.2.jar:5.6.2]
	at org.elasticsearch.index.query.QueryShardContext.lambda$toQuery$1(QueryShardContext.java:313) ~[elasticsearch-5.6.2.jar:5.6.2]
.
.
.
Caused by: java.lang.IllegalArgumentException: script_lang not supported [expert_scripts]
	at org.elasticsearch.script.ScriptService.getScriptEngineServiceForLang(ScriptService.java:189) ~[elasticsearch-5.6.2.jar:5.6.2]
	at org.elasticsearch.script.ScriptService.compile(ScriptService.java:261) ~[elasticsearch-5.6.2.jar:5.6.2]
	at org.elasticsearch.script.ScriptService.search(ScriptService.java:491) ~[elasticsearch-5.6.2.jar:5.6.2]
	at org.elasticsearch.index.query.QueryShardContext.getSearchScript(QueryShardContext.java:345) ~[elasticsearch-5.6.2.jar:5.6.2]
	at org.elasticsearch.index.query.functionscore.ScriptScoreFunctionBuilder.doToFunction(ScriptScoreFunctionBuilder.java:97) ~[elasticsearch-5.6.2.jar:5.6.2]

```

Can anyone give me a hint on whats wrong ?

Thanks  
Srini

---

<div class="post-metadata">

**Author:** ![Srinivasan\_Ramaswamy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/srinivasan_ramaswamy/32/74106_2.png) [@Srinivasan\_Ramaswamy](https://discuss.elastic.co/u/Srinivasan_Ramaswamy)\
**Post date:** [November 1, 2017, 7:30am UTC](https://discuss.elastic.co/t/script-score-the-script-could-not-be-loaded/105816/2 "2017-11-01T07:30:21Z")

</div>

I figured it out. I forgot to implement ScriptPlugin. The example mentioned in the above url, should be enclosed like this

```
public class ExpertScriptPlugin extends Plugin implements ScriptPlugin {

    @Override
    public ScriptEngineService getScriptEngineService(Settings settings) {
        return new MyExpertScriptEngine();
    }

   /* class given in the example */
   private static class MyExpertScriptEngine implements ScriptEngineService {
   }
}
```

---

<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:** [November 29, 2017, 7:30am UTC](https://discuss.elastic.co/t/script-score-the-script-could-not-be-loaded/105816/3 "2017-11-29T07:30:39Z")

</div>

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