Help with scripted fields

I'm a complete beginner with Kibana and its my first time creating a scripted field. I'm creating a script to retrieve the transaction id's of dropped transactions from all my transaction logs.

Below is the script which contains an error that I don't understand. It'd be great if someone could explain it to me and provide me with tips for a fix.

</>
string current = "abc";
for (def log1 : doc['invoice_id'].values {
if (log1 != current) {
log1 = current;
for (def log2 : doc['invoice_id'].values) {
if (log2 == current) {
if (doc['log_type'].values.contains("MER_REQUEST")) {
if (doc['log_type'].values.contains("MER_RESPONSE")) {
}
else {
return current;
}
}
}
}
}
}
</>

I am not sure I understand what you are trying to achieve. Be aware that the scripted field runs in the context of a single document, so you can not compare values from different documents (if that is what you are trying to do).

Oh, I was actually trying to compare values from different logs. Thanks for the help, I'll try to find a workaround. Also, sorry that my question wasn't clear.

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