Reputation: 914
Is there a way that I can specify Groovy script file name in "script" textarea while creating a scripted field.
Lucene expressions work well on that field with limitations to numeric values, but how to specify the script file name and passing inputs to script file?
I have tried giving the script file name like below but it didn't work.
{"script":{"file":"MyScript"},"lang":"groovy"}
I have also noticed from docs that, latest elastic version defaults to Lucene expressions, but I suspect there should be a way to specify script type.
UPDATE: As a security precaution, starting with version 4.0.0-RC1, Kibana scripted fields default to Lucene Expressions, not Groovy, as the scripting language.
Can someone let me know if it is possible and if possible, then the way of doing it?
Upvotes: 1
Views: 1429
Reputation: 5823
The following instruction are for elasticsearch
2.x.
First you need to enable Groovy aggregations scripts in elasticsearch.yml
:
script.engine.groovy.indexed.aggs: true
Then in your JSON Input of the relevant property in your visualization:
Lastly you need to put your script in the config/scripts
folder
elasticsearch
└── config
└── scripts
└── myscript.groovy
Don't forget to restart your elasticsearch
after the above changes.
Upvotes: 1