Hi!
It's been a while since I last wrestled with logstash, and I can feel the rust!
I'm trying to delete an array element with delete_if
, and I have trouble with it.
The element itself is a dictionary, and the condition to delete it is that one of the entries of this dictionary must be empty (or nil
).
The data I get is a dictionary, data
, which contains several key-value pairs. One of them, features
, is itself a list of dictionaries. Said dictionaries contain several key-value pairs, one of which, geometry
, is a dictionary containing two key-value pairs: type
and coordinates
.
data
{
key_1: val_1
features: [
{
key_1: val_1
geometry: {
type: "MultiPoint"
coordinates: [
1.3498...
43.349...
]
}
...
key_n: val:n
},
{...},
...
{...}
]
...
key_n: val_n
}
I need to delete those features which geometry
is empty.
This is what I tried:
event.set('data_feat', event.get('[data][features]').delete_if {|a| ! a[geometry][type]})
event.set('[data][features]', 'data_feat')
Got this error:
"Ruby exception occurred: undefined local variable or method `geometry' ..."
What am I doing wrong? Any ideas?
Thank you in advance!