# Pipeline to update the nested documents

**URL:** <https://discuss.elastic.co/t/pipeline-to-update-the-nested-documents/208375>\
**Category:** Logstash\
**Created:** [November 18, 2019, 6:54pm UTC](https://discuss.elastic.co/t/pipeline-to-update-the-nested-documents/208375 "2019-11-18T18:54:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TimurAralov](https://avatars.discourse-cdn.com/v4/letter/t/a5b964/32.png) [@TimurAralov](https://discuss.elastic.co/u/TimurAralov)\
**Post date:** [November 18, 2019, 6:54pm UTC](https://discuss.elastic.co/t/pipeline-to-update-the-nested-documents/208375/1 "2019-11-18T18:54:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 16, 2019, 6:54pm UTC](https://discuss.elastic.co/t/pipeline-to-update-the-nested-documents/208375/2 "2019-12-16T18:54:55Z")

</div>

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