# How to perform join with two or more csv files into one index of elastic search using logstash

**URL:** https://discuss.elastic.co/t/how-to-perform-join-with-two-or-more-csv-files-into-one-index-of-elastic-search-using-logstash/114865
**Category:** Logstash
**Created:** [January 10, 2018, 12:17pm UTC](https://discuss.elastic.co/t/how-to-perform-join-with-two-or-more-csv-files-into-one-index-of-elastic-search-using-logstash/114865 "2018-01-10T12:17:45Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jagadeesh](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@Jagadeesh](https://discuss.elastic.co/u/Jagadeesh)
#### Post date: [January 10, 2018, 12:17pm UTC](https://discuss.elastic.co/t/how-to-perform-join-with-two-or-more-csv-files-into-one-index-of-elastic-search-using-logstash/114865/1 "2018-01-10T12:17:45Z")

</div>

I have created two CSV files A.csv and B.csv.  
A.csv has the fields id,name,city etc. (10 records)  
B.csv has fields id,age,blood\_group etc (10 records)  
In both the above files id field is common. so can I create an index in elastic search from these two CSV files, so that the index will have only the unique records from both the CSV files.

I am using logstash to insert data into elastic search ,

please suggest me the way to implement this

---

<div class="post-metadata">

### Author: ![Jagadeesh](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@Jagadeesh](https://discuss.elastic.co/u/Jagadeesh)
#### Post date: [January 10, 2018, 12:20pm UTC](https://discuss.elastic.co/t/how-to-perform-join-with-two-or-more-csv-files-into-one-index-of-elastic-search-using-logstash/114865/2 "2018-01-10T12:20:38Z")

</div>

Here is my config file,

input {  
file {  
path =\> "D:\ELK\logstash-6.1.1\bin\input\employee.csv"  
start\_position =\> "beginning"  
}  
file {  
path =\> "D:\ELK\logstash-6.1.1\bin\input\dept.csv"  
start\_position =\> "beginning"  
}  
file {  
path =\> "D:\ELK\logstash-6.1.1\bin\input\employee\_dept.csv"  
start\_position =\> "beginning"  
}  
}  
filter {  
if [path] == "D:\ELK\logstash-6.1.1\bin\input\employee.csv"  
{  
csv {  
separator =\> ","  
columns =\>["emp\_id","employee\_name","designation","department\_id","salary"]  
}  
}  
else if [path] == "D:\ELK\logstash-6.1.1\bin\input\dept.csv" or [path] == "D:\ELK\logstash-6.1.1\bin\input\employee\_dept.csv"  
{  
csv {  
separator =\> ","  
columns =\>["emp\_id","employee\_name","designation","department\_id","salary","department\_id","department\_name"]  
}  
}  
}  
output {  
elasticsearch {  
hosts =\> "localhost:9200"  
index =\> "test"  
user =\> "elastic"  
password =\> "43y2\*k1TOqwFUIjYBMb!"  
}  
stdout {codec =\> rubydebug}  
}

---

<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: [February 7, 2018, 12:20pm UTC](https://discuss.elastic.co/t/how-to-perform-join-with-two-or-more-csv-files-into-one-index-of-elastic-search-using-logstash/114865/3 "2018-02-07T12:20:55Z")

</div>

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