Javascript script to compute calculated field


I have JavaScript plugin installed. I can use inline javascript for script
property, but cannot reference a javascript file name similar to article.

I can put a groovy script in there and reference it just fine.

Can you help me, this is my javascript, maybe even help convert into groovy

function calculate-scenariotime(match) {
var elapsedtime = new Array();
var cStart;
var j = 0;
for (var i = 0; i <; i++) {
if ([i].name === match[j]) {
if (j === 0) {
cstart =[i].start;
if (j === match.length - 1) {
var dur = (Date.parse([i].end) -
Date.parse(cstart)) / 1000;
elapsedtime[elapsedtime.length] = dur;
j = -1;
else {
j = 0;
return elapsedtime;

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
To view this discussion on the web visit
For more options, visit