# Create multiple indices grouped by a field

**URL:** <https://discuss.elastic.co/t/create-multiple-indices-grouped-by-a-field/88462>\
**Category:** Logstash\
**Created:** [June 6, 2017, 7:04pm UTC](https://discuss.elastic.co/t/create-multiple-indices-grouped-by-a-field/88462 "2017-06-06T19:04:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![munotshubham](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/munotshubham/32/22663_2.png) [@munotshubham](https://discuss.elastic.co/u/munotshubham)\
**Post date:** [June 6, 2017, 7:04pm UTC](https://discuss.elastic.co/t/create-multiple-indices-grouped-by-a-field/88462/1 "2017-06-06T19:04:35Z")

</div>

Hi,

I have a .csv file with 2 million records and I am using logstash to index the .csv file.  
I do not want to index all records in one index. So I want them to index them based on say states. So basically I'll have 50 indices.

try-"state name"  
eg:  
try-NY  
try-NC  
try-MD etc.

Can I do this?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [June 11, 2017, 12:32pm UTC](https://discuss.elastic.co/t/create-multiple-indices-grouped-by-a-field/88462/2 "2017-06-11T12:32:08Z")

</div>

Yes, just reference the name of the field containing the state name or abbreviation in the elasticsearch output's `index` option, e.g.

```
index => "try-%{state}"
```

---

<div class="post-metadata">

**Author:** ![munotshubham](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/munotshubham/32/22663_2.png) [@munotshubham](https://discuss.elastic.co/u/munotshubham)\
**Post date:** [June 13, 2017, 1:49pm UTC](https://discuss.elastic.co/t/create-multiple-indices-grouped-by-a-field/88462/3 "2017-06-13T13:49:01Z")

</div>

Thanks

---

<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:** [July 11, 2017, 1:49pm UTC](https://discuss.elastic.co/t/create-multiple-indices-grouped-by-a-field/88462/4 "2017-07-11T13:49:21Z")

</div>

Closed on July 11, 2017, 1:49pm UTC

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