Groovy parseText to json

I want to parse Text to json in groovy script
but get errors:

failed to load/compile script [my_script]

This is my_script.groovy file:


json=new groovy.json.JsonSlurper().parseText(body);

obj = json
for(String p : paths) {
if(obj==val) {
return true
} else {
return false

after some debug,problem may comes from "json=new groovy.json.JsonSlurper().parseText(body);"

anyone can help me? thx

(ElasticSearver version: 2.4.1)

Jsonslurper is not supported iirc.

What class should I use instead?

after google,i found a solution:

  1. drop in the ${ELASTICSEARCH_HOME}/modules/lang-groovy/ directory for it to work.
  2. add permissions to file: ${ELASTICSEARCH_HOME}/modules/lang-groovy/plugin-security.policy
    permission org.elasticsearch.script.ClassPermission "groovy.json.JsonSlurper";

it works only in:
./bin/elasticsearch -d --security.manager.enabled
es version:2.4.2

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