Hi, Im running a chained input watch with two queries: "first" and "second", and comparing the fields partition_field_value from "first" against hostname from "second", Im certain that in both indexes exist a partition_field_value with the same value as a hostname, but I keep getting this error:
"type" : "script_exception",
"reason" : "runtime error",
"script_stack" : [
"java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)",
"java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)",
"java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)",
"java.base/java.util.Objects.checkIndex(Objects.java:373)",
"java.base/java.util.ArrayList.get(ArrayList.java:425)",
"if (ctx.payload.first.hits.hits[i]._source.partition_field_value == ctx.payload.second.hits.hits[i]._source.hostname) { ",
" ^---- HERE"
],
The weird thing is that my condition works and its almost the same code that is in the transform
"condition": {
"script": {
"source": "for (int i = 0; i < ctx.payload.second.hits.total; ++i) {
if (ctx.payload.first.hits.hits[i]._source.partition_field_value == ctx.payload.second.hits.hits[i]._source.hostname) { return true;}
}",
"lang": "painless"
}
},
"actions": {
"my-logging-action": {
"transform": {
"script": {
"source": "ctx.payload.transform = [];
def document = [];
for (int i = 0; i < ctx.payload.second.hits.total; ++i) {
if (ctx.payload.first.hits.hits[i]._source.partition_field_value == ctx.payload.second.hits.hits[i]._source.hostname) {
document = ['hostname': ctx.payload.second.hits.hits[i]._source.hostname];
ctx.payload.transform.add(document)
}
} return ctx.payload.transform;",
"lang": "painless"
}
},
"logging": {
"level": "warn",
"text": "true match {{#ctx.payload._value}} {{hostname}} {{/ctx.payload._value}}"
}
}
}
When I do both queries outside the watcher, they both return results
What is wrong with my transform script?