# Add and cut field on specific characters based on index name

**URL:** <https://discuss.elastic.co/t/add-and-cut-field-on-specific-characters-based-on-index-name/145584>\
**Category:** Logstash\
**Created:** [August 22, 2018, 3:52pm UTC](https://discuss.elastic.co/t/add-and-cut-field-on-specific-characters-based-on-index-name/145584 "2018-08-22T15:52:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sbienert](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@sbienert](https://discuss.elastic.co/u/sbienert)\
**Post date:** [August 22, 2018, 3:52pm UTC](https://discuss.elastic.co/t/add-and-cut-field-on-specific-characters-based-on-index-name/145584/1 "2018-08-22T15:52:12Z")

</div>

Hello,

I want to add a field and fill it with the value of the index name but cut it after the first underscore and before the third underscore. I have an Elasticsearch in- and output and want to reindex with wildcard in index name so that all indices containing the pattern are fetched by the input.

What I have:  
`{ "_index": "xxx_yyy_value_zzz" }`

What I want:  
`{ "_index": "xxx_yyy_value_zzz", "_source": { "field": "value" } }`

Can you also transmit the value or the whole input index name to the Elasticsearch Output index name when you have wildcards for input indices?

Thanks

---

<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:** [August 25, 2018, 2:07pm UTC](https://discuss.elastic.co/t/add-and-cut-field-on-specific-characters-based-on-index-name/145584/2 "2018-08-25T14:07:29Z")

</div>

As I recall the input index name ends up in a field when using the elasticsearch input. You can use a dissect or grok filter to extract parts of that string into separate fields.

---

<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:** [September 22, 2018, 2:07pm UTC](https://discuss.elastic.co/t/add-and-cut-field-on-specific-characters-based-on-index-name/145584/3 "2018-09-22T14:07:31Z")

</div>

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