# Rollover api and dynamic indices based on fields

**URL:** <https://discuss.elastic.co/t/rollover-api-and-dynamic-indices-based-on-fields/124940>\
**Category:** Elasticsearch\
**Created:** [March 21, 2018, 9:14am UTC](https://discuss.elastic.co/t/rollover-api-and-dynamic-indices-based-on-fields/124940 "2018-03-21T09:14:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dao](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@dao](https://discuss.elastic.co/u/dao)\
**Post date:** [March 21, 2018, 9:14am UTC](https://discuss.elastic.co/t/rollover-api-and-dynamic-indices-based-on-fields/124940/1 "2018-03-21T09:14:26Z")

</div>

Hello,

I have a logstash that pushes the data in a dynamic index based on a field value. I want to use the rollover API to let elasticsearch manage my index+shard creation.

```auto
mutate {
    add_field => {
      "[@metadata][index]" => "wilco-%{site}-%{fwot_type}-%{layout_id}-v1"
output {
  elasticsearch {
    index => "%{[@metadata][index]}"

```

The problem is that I have to precreate the indices with the alias, but I cannot know the names in advance as it comes from the fields.

Is there a solution like the \_template solution to say to es

> if you create an index with this pattern, then create this associated alias

---

<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:** [April 18, 2018, 9:14am UTC](https://discuss.elastic.co/t/rollover-api-and-dynamic-indices-based-on-fields/124940/2 "2018-04-18T09:14:36Z")

</div>

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