Adding geopoints to nested objects in an array of parent document

I have a parent and an array of nested objects called children. I am getting lat and lng(longitude) from my sql join query. I want to create geo_point in nested objects of parents contained in an array using lat and lng. I tried different methods but couldn't do it.

filter {
aggregate {
task_id => "%{id}"
code => "
map['id'] = event.get('id')
map['name'] = event.get('name')
map['lat'] = event.get('lat')
map['lng'] = event.get('lng')
map['list'] ||=
map['children'] ||=
if (event.get('child_id') != nil)
if !( map['list'].include? event.get('child_id') )
map['list'] << event.get('child_id')
map['children'] << {
'child_id' => event.get('child_id'),
'street_address' => event.get('street_address')
}
end
end
event.cancel()
"
push_previous_map_as_event => true
timeout => 15
}
mutate {
add_field => { "[children][location][lat]" => "%{lat}" }
add_field => { "[children][location][lon]" => "%{lng}" }
}
mutate {
convert => {"[location][lat]" => "float"}
convert => {"[location][lon]" => "float"}
}
}

Do you have an index mapping template that tells elasticsearch that the [location] and [children][location] fields are geo_points?

Hi Badger, I have read your answer and thanks for all the help.
However I solved this problem by setting up a mapping for geo_point.
Now I want to sort results according to some field in nested objects but I am not able to do. I have an array of nested objects with field cost.

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