Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript plugin seems broken #2849

Closed
clintongormley opened this issue Apr 3, 2013 · 4 comments
Closed

Javascript plugin seems broken #2849

clintongormley opened this issue Apr 3, 2013 · 4 comments

Comments

@clintongormley
Copy link

In 0.20.6, with the 1.3.0 JS plugin, I'm struggling to get anything to work. Perhaps I'm misunderstanding?

For instance, I'm trying to return a simple value as a script field. Any of the following requests throws a similar error (below):

curl -XGET 'http://127.0.0.1:9200/_all/_search?pretty=1'  -d '
{
   "script_fields" : {
      "foo" : {
         "script" : "return 5",
         "lang" : "js"
      }
   }
}
'
curl -XGET 'http://127.0.0.1:9200/_all/_search?pretty=1'  -d '
{
   "script_fields" : {
      "foo" : {
         "script" : "return 5.0",
         "lang" : "js"
      }
   }
}
'
curl -XGET 'http://127.0.0.1:9200/_all/_search?pretty=1'  -d '
{
   "script_fields" : {
      "foo" : {
         "script" : "return \u0027foo\u0027",
         "lang" : "js"
      }
   }
}
'
curl -XGET 'http://127.0.0.1:9200/_all/_search?pretty=1'  -d '
{
   "script_fields" : {
      "foo" : {
         "script" : "return \"foo\"",
         "lang" : "js"
      }
   }
}
'

'

[2013-04-03 12:22:06,596][DEBUG][action.search.type       ] [Ord] [test][1], node[SRNRWFu0QS2JTeRrD1-lrw], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@3b25ad0d]
org.elasticsearch.search.SearchParseException: [test][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{
   "script_fields" : {
      "foo" : {
         "script" : "return 5",
         "lang" : "js"
      }
   }
}
]]
    at org.elasticsearch.search.SearchService.parseSource(SearchService.java:566)
    at org.elasticsearch.search.SearchService.createContext(SearchService.java:481)
    at org.elasticsearch.search.SearchService.createContext(SearchService.java:466)
    at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:236)
    at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:141)
    at org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)
    at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:205)
    at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:192)
    at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:178)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
Caused by: org.mozilla.javascript.EvaluatorException: invalid return (Script12.js#1)
    at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:77)
    at org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:64)
    at org.mozilla.javascript.Parser.addError(Parser.java:188)
    at org.mozilla.javascript.Parser.addError(Parser.java:166)
    at org.mozilla.javascript.Parser.reportError(Parser.java:223)
    at org.mozilla.javascript.Parser.reportError(Parser.java:210)
    at org.mozilla.javascript.Parser.reportError(Parser.java:203)
    at org.mozilla.javascript.Parser.returnOrYield(Parser.java:1623)
    at org.mozilla.javascript.Parser.statementHelper(Parser.java:999)
    at org.mozilla.javascript.Parser.statement(Parser.java:901)
    at org.mozilla.javascript.Parser.parse(Parser.java:540)
    at org.mozilla.javascript.Parser.parse(Parser.java:478)
    at org.mozilla.javascript.Context.compileImpl(Context.java:2348)
    at org.mozilla.javascript.Context.compileString(Context.java:1335)
    at org.mozilla.javascript.Context.compileString(Context.java:1324)
    at org.elasticsearch.script.javascript.JavaScriptScriptEngineService.compile(JavaScriptScriptEngineService.java:90)
    at org.elasticsearch.script.ScriptService.compile(ScriptService.java:175)
    at org.elasticsearch.script.ScriptService.search(ScriptService.java:193)
    at org.elasticsearch.search.fetch.script.ScriptFieldsParseElement.parse(ScriptFieldsParseElement.java:73)
    at org.elasticsearch.search.SearchService.parseSource(SearchService.java:554)
    ... 11 more
@clintongormley
Copy link
Author

Wrong version of JS plugin - closing

@clintongormley
Copy link
Author

Actually, in 0.20.6 with JS plugin 1.2.0, i'm still getting parse errors. What's going on here?

@clintongormley clintongormley reopened this Apr 3, 2013
@clintongormley
Copy link
Author

Ah, it might be because i'm using return outside a function. Is there any chance of being able to see the parse error from the JS engine, rather than the Java stacktrace which is meaningless here?

@clintongormley
Copy link
Author

It seems the error is there, just hidden in the flood of stack trace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant