# Failed to load javascript script in Elasticsearch

**URL:** <https://discuss.elastic.co/t/failed-to-load-javascript-script-in-elasticsearch/1210>\
**Category:** Elasticsearch\
**Created:** [May 23, 2015, 5:38pm UTC](https://discuss.elastic.co/t/failed-to-load-javascript-script-in-elasticsearch/1210 "2015-05-23T17:38:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhishekbatra](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@abhishekbatra](https://discuss.elastic.co/u/abhishekbatra)\
**Post date:** [May 23, 2015, 5:38pm UTC](https://discuss.elastic.co/t/failed-to-load-javascript-script-in-elasticsearch/1210/1 "2015-05-23T17:38:23Z")

</div>

I wrote a javascript script for `script_score` in `function_score`, but I get the following error on elasticsearch service start. I am running Ubuntu 14.04, elasticsearch 1.4.5. I sadly cannot post the code here.

> [2015-05-23 21:00:18,093][INFO][script] [Soulfire] compiling script file [/etc/elasticsearch/scripts/**.js] [2015-05-23 21:00:18,180][WARN][script] [Soulfire] failed to load/compile script [**] org.mozilla.javascript.EvaluatorException: invalid return (Script1.js#14)

I tried a script with just `return 0.5;`. I still get the error:

> [2015-05-23 22:52:48,527][INFO][script] [Warrior Woman] compiling script file [/etc/elasticsearch/scripts/test.js] [2015-05-23 22:52:48,609][WARN][script] [Warrior Woman] failed to load/compile script [test] org.mozilla.javascript.EvaluatorException: invalid return (Script1.js#1)

What would constitute a valid return value? Is there any way to debug the score script or print to elasticsearch logs? Its the first time I'm trying out the scripting feature, so can't figure out what could be wrong. Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![ppf2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppf2/32/52219_2.png) [@ppf2](https://discuss.elastic.co/u/ppf2)\
**Post date:** [September 2, 2015, 1:26am UTC](https://discuss.elastic.co/t/failed-to-load-javascript-script-in-elasticsearch/1210/2 "2015-09-02T01:26:40Z")

</div>

Tested this briefly, you don't have to use a return statement in the script, just the float value, so if just put 0.5 in the .js file it will set the score to 0.5.

---

<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:52pm UTC](https://discuss.elastic.co/t/failed-to-load-javascript-script-in-elasticsearch/1210/3 "2017-07-05T23:52:46Z")

</div>


