Preloaded scripts example

Hi! Could someone show a simple script (javascript, python) that is stored
in scripts directory and takes some arguments? Could it be a user-defined
function? Some example of script and its usage would be very helpful.
Thanks!

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

I have a query like this:

{
"query": {
...
},
"facets" : {
"tag": {
"terms": {
"field": "timers",
"script": "myscript",
"params": {
"tag" : "foo"
},
"lang": "python"
}
}
}
}

Which calls myscript.py on the server. The python variable 'tag' is set to
the value 'foo' when the script starts.

My script doesn't do everything that I want (since I've also been unable to
find any examples), but it does do this part properly...

Note that you have to restart ES when you make changes to the script.

On Wednesday, February 6, 2013 1:12:26 AM UTC-8, andrexus wrote:

Hi! Could someone show a simple script (javascript, python) that is stored
in scripts directory and takes some arguments? Could it be a user-defined
function? Some example of script and its usage would be very helpful.
Thanks!

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

@rastro can you please share the content of myscript.py

I'm trying to write a script that will extract some content based on the parameter passed to the script and return that content as a new field in the response.

Sorry, @bikrant, but I don't even remember what project that was for 9 months ago :frowning: