我正在将ElasticSearch从1.2升级到2.2.我成功地通过一些重大的API更改进行了挖掘.我发现script_score中的groovy脚本不起作用.我启用了动态脚本
script.inline=true
script.indexed=true
Run Code Online (Sandbox Code Playgroud)
我包括groovy-all 2.4.6.我还添加了jna和mustache,以便在嵌入式ElasticSearch启动时看不到任何异常.
我的嵌入式服务器的配置是:
ESLoggerFactory.setDefaultFactory(new Slf4jESLoggerFactory());
Settings settings = Settings.builder()
.put("node.name" ,getName())
.put("path.home", "/tmp/elastic-search/home")
.put("path.shared_data", /tmp/elastic-search")
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, "1")
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, "0")
.put("action.auto_create_index", "0")
.put("index.gateway.type", "none")
.put("script.inline", true)
.put("script.indexed", true)
.put("action.destructive_requires_name", false)
.build();
node = nodeBuilder().clusterName(clusterName).settings(settings).node();
Run Code Online (Sandbox Code Playgroud)
然后我执行一个查询,其中包含一个看起来像loke的function_score/functions下的代码片段:
"filter" : {
"exists" : {
"field" : "transactionCount"
}
},
"script_score" : {
"script" : {
"inline" : "doc['transactionCount'].value/10.0"
}
}
Run Code Online (Sandbox Code Playgroud)
执行抛出:
Caused by: org.elasticsearch.index.query.QueryParsingException: script_score the script could not be loaded
...
Caused by: java.lang.IllegalArgumentException: script_lang not supported [groovy]
at org.elasticsearch.script.ScriptService.getScriptEngineServiceForLang(ScriptService.java:211) …Run Code Online (Sandbox Code Playgroud)