Hello, i have an input with ( besides other data) 2 Arrays , event_type and duration_ms.
i use logstash to update the document with this data. Because i don't want to loose the data from event_type and duration, i just add the values to an array in the original document.
My Problem is, that duration_ms does not always exist, therefore i am currently trying to add an if statement, because otherwise the script would fail.
my problem is, that with the current config:
output {
elasticsearch {
index => "kafka_import"
action => "update"
doc_as_upsert => "true"
document_id => "%{click_uuid}"
script => 'ctx._source.event_type.add("%{event_type}"); if(ctx._source.duration_ms != null) { ctx._source.duration_ms.add("%{duration_ms}");}'
}
}
the output is
0, %{duration_ms}, %{duration_ms}, %{duration_ms}, %{duration_ms}, 9000, %{duration_ms}
Can someone point me into the right direction how to check if the field has a value?