I am using Multiple Jdbc input plugins(since I have two Sqls , one is parent and other is child table) to load data into elastic which has parent child relationship between two mappings. Can you please provide me sample code how to load parent document id into child document. I used parent config option of Elastic output plugin but didnot work.
It is quite simple, but depends on your configuration a lot. So if you use aggregate filter plugin and define a parent child relation...like:
filter {
aggregate {
task_id => "%{some_id}"
code => "
map['parent] ||= {}
map['parent_id'] = event.get('parent_id')
map['parent_name'] = event.get('parent_name')
map['parent']['child'] ||= []
map['parent']['child'] << {'child_id' => event.get('child_id'),'child_name' => event.get('child_name'),'parent_id' => event.get('parent_id')}
event.cancel()
"
push_previous_map_as_event => true
timeout => 5
}
}
Thank you. It worked.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.