# Indexing multiple csv files into one index with nested fields

**URL:** <https://discuss.elastic.co/t/indexing-multiple-csv-files-into-one-index-with-nested-fields/322687>\
**Category:** Logstash\
**Created:** [January 8, 2023, 7:21pm UTC](https://discuss.elastic.co/t/indexing-multiple-csv-files-into-one-index-with-nested-fields/322687 "2023-01-08T19:21:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivandreev1618](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivandreev1618/32/115690_2.png) [@ivandreev1618](https://discuss.elastic.co/u/ivandreev1618)\
**Post date:** [January 8, 2023, 7:21pm UTC](https://discuss.elastic.co/t/indexing-multiple-csv-files-into-one-index-with-nested-fields/322687/1 "2023-01-08T19:21:08Z")

</div>

I want to load data from multiple CSV files(Users, Scores, Messages) into one index via logstash.  
All CSV files have the same "userId" field that connects data in it.

My goal is to have User-Index as a result, that has the data from the User CSV file as simple fields and the data from Scores and Messages files as nested fields.

Is there a way to somehow achieve this?

One user can have multiple messages and scores.

---

<div class="post-metadata">

**Author:** ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)\
**Post date:** [January 9, 2023, 10:25pm UTC](https://discuss.elastic.co/t/indexing-multiple-csv-files-into-one-index-with-nested-fields/322687/2 "2023-01-09T22:25:10Z")

</div>

Welcome [ivandreev1618](https://discuss.elastic.co/u/ivandreev1618)

You can use upsert and userid as the document id. After you import all 3 file types (Users, Scores, Messages) then go to Kibana and create data view.

```auto
output {
   elasticsearch {
      hosts => ["http://localhost:9200"]
      index => "user-score-msg"
      document_id => "%{userid}"
   }
}

```

---

<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 6, 2023, 10:25pm UTC](https://discuss.elastic.co/t/indexing-multiple-csv-files-into-one-index-with-nested-fields/322687/3 "2023-02-06T22:25:24Z")

</div>

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