Pipeline to update the nested documents

Hi everyone. I'm currently syncing the RDB and Elasticsearch via JDBC plugin databases.

Index looks like (names are replaced with readable AAA, BBB and CCC) :

PUT indexname
{ 
...
	"mappings" : {
		"properties" : {
			"id" : {   
				"type" : "keyword"
			},
			"aaa" : {
				"type" : "nested",
				"dynamic" : "false",
				"properties" : {
					"bbb_id" : {   
						 "type" : "keyword"
					},
					"bbb" : {
						"type" : "nested",
						"dynamic" : "false",
						"properties" : {
							"ccc_id" : {   
								"type" : "keyword"
							},
							"ccc" : {   
								"type" : "keyword"
							}
						}
					}
				}
			}
		}
	}
}

My logstash filter- and output plugins look like:

filter {
	aggregate {
		task_id => "%{[aaa][bbb_id]}"
		code => "
			map['bbb_id']	||= event.get('sqlfield1')
			map['bbb']		||= []
			map['bbb']		<< {
				'ccc_id'		=> event.get('sqlfield2'),	
				'ccc'			=> event.get('sqlfield3'),
			}
			event.cancel()
		"
		push_previous_map_as_event => true
		timeout => 5
	}
}
output {
    elasticsearch {
        index => "indexname"
        document_id => "%{[aaa][bbb_id]}"
        hosts => ["localhost:9200"]
        action => "update"
        doc_as_upsert => true
    }
}

The field BBB is not populated with the nested documents though. Might you please tell where there's a mistake?

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