I don't know if you've already resolved the issue, but you need to refer to the manual here:
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html#enable-dynamic-scripting
Basically, you need to enable groovy language for your specific need. Mine was to add:
script.engine.groovy.inline.search: off