Failed to load javascript script in Elasticsearch


(Abhishek Batra) #1

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.


#2

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.


(system) #3