# Append field if document\_id already exists

**URL:** <https://discuss.elastic.co/t/append-field-if-document-id-already-exists/120742>\
**Category:** Logstash\
**Created:** [February 20, 2018, 11:55pm UTC](https://discuss.elastic.co/t/append-field-if-document-id-already-exists/120742 "2018-02-20T23:55:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Baljeet\_Dogra](https://avatars.discourse-cdn.com/v4/letter/b/b2d939/32.png) [@Baljeet\_Dogra](https://discuss.elastic.co/u/Baljeet_Dogra)\
**Post date:** [February 20, 2018, 11:55pm UTC](https://discuss.elastic.co/t/append-field-if-document-id-already-exists/120742/1 "2018-02-20T23:55:47Z")

</div>

I have a csv file with multiple records for each document where the data is partially different.

doc\_id insurance\_policy policy\_holder  
C12 P-C12-2017 Michal  
C12 P-C12-2017 Sophie  
C12 P-C12-2017 Adam  
C12 P-C12-2017 Peter

I am processing the above csv file using the csv plugin in Logstash to insert data into elastic.  
Instead of having 4 documents in elastic, my requirement is to have only one document with all data in it.

Intended document in elastic  
{  
\_id: C12,  
policy: P-C12-2017,  
holders: [Michal, Sophie, Adam, Peter]  
}

How can I achieve this using Logstash?

(I tried using elasticsearch plugin to lookup already existing document to fetch the policy\_holder data but this only picks up one entry)

---

<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:** [March 20, 2018, 11:55pm UTC](https://discuss.elastic.co/t/append-field-if-document-id-already-exists/120742/2 "2018-03-20T23:55:53Z")

</div>

Closed on March 20, 2018, 11:55pm UTC

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