Error with a groovy script

Hi,
I'm using ES 2.3.1, and I've written a simple groovy script which merges the documents. Script loads well and runs good at times, but after some time it gives an error: message [java.lang.IllegalArgumentException: failed to execute script]

What could be wrong ? How can I debug more ? Can we catch exceptions in groovy script ? Or log ?

My script is given below:

if (ctx._source.'field-1' != null) {
ctx._source.'num_hits' = ctx._source.'field-1'.size() + one
} else {
ctx._source.'num_hits' = one
}
if (ctx._source.'field-1' != null) {
ctx._source.'field-1'.add(param_1)
} else {
ctx._source.'field-1' = [param_1]
}
if (ctx._source.'field-2' != null) {
ctx._source.'field-2'.add(param_2)
} else {
ctx._source.'field-2' = [param_2]
}
if (ctx._source.'field-3' != null) {
ctx._source.'field-3'.add(param_3)
} else {
ctx._source.'field-3' = [param_3]
}
if (ctx._source.'field-4' != null) {
ctx._source.'field-4'.add(param_4)
} else {
ctx._source.'field-4' = [param_4]
}

field-1, and field-3 are string arrays.
field-2 and field-4 are long arrays.
I always pass on at-least 5 params: one, param_1, param_2, param_3, param_4 (plus there could be more params)
one is int, param_1 and param_3 are strings, param_2 and param_4 are longs.

Thanks,
..... Amol

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