How to call stored script from another script?

Hey,
I have a stored script which does some calculation and returns a number. I'm using it to populate a scripted field. And I need to use the pretty much same script for filtering out the results. Firstly, I try to access the scripted field in order to use it for filtering but apparently, we cannot access the scripted field from other scripts.
So, I wonder if it is possible to call the stored script from another script or not?

// something like this
{
"filter": {
"script": {
"script": {
"source": "_scripts.foo_stored_script(params) > THRESHOLD"
}}}}

Is it possible to do this? Or is there an easier way to do something like this?

Thanks

Unfortunately, this is not possible. There is no infrastructure to call scripts from within scripts in ES. My recommendation would be to create a method within one the Painless scripts that can be copy/pasted to others if the same code needs to be re-used.

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