# How to use the SAME mapping for all similar indices, and then for all types in the index?

**URL:** <https://discuss.elastic.co/t/how-to-use-the-same-mapping-for-all-similar-indices-and-then-for-all-types-in-the-index/80523>\
**Category:** Elasticsearch\
**Created:** [March 29, 2017, 4:59pm UTC](https://discuss.elastic.co/t/how-to-use-the-same-mapping-for-all-similar-indices-and-then-for-all-types-in-the-index/80523 "2017-03-29T16:59:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZillaG](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zillag/32/10505_2.png) [@ZillaG](https://discuss.elastic.co/u/ZillaG)\
**Post date:** [March 29, 2017, 4:59pm UTC](https://discuss.elastic.co/t/how-to-use-the-same-mapping-for-all-similar-indices-and-then-for-all-types-in-the-index/80523/1 "2017-03-29T16:59:10Z")

</div>

ES 2.4.1

I create a daily logstash index to meet my needs, which has the form "logstash-application-customer-YYYY.MM.dd" where the YYYY.MM.dd is of course the value that meets the "daily" requirement. I can have many applications and many customers, but those do not change daily.

So per the API I got my mapping and got this sample snippet

```
{
  "logstash-applicationX-customer-2017.03.29" : {
    "mappings" : {
      "appX_type_log_1" : {
          # Mappings for log_1 types
       }
      "appX_type_log_2" : {
          # Mappings for log_2 types
       }
    }
  }
}

```

I need different types because my Grok filters are conditioned on these types, though I do have the same fields for ALL the types for each application.

This means that I'll have a different mapping for an index created on a different day, which will look exactly the same as the above mapping, correct? Also I noticed that the type\_log\_1 mappings, are EXACTLY the same as the type\_log\_2 mappings. So how can I create a mapping that essentially does this for applicationX

```
{
  "logstash-applicationX-*" : {
    "mappings" : {
      "appX_type_*" : {
          # Mappings for ALL types for logstash-applicationX-*
       }
    }
  }
}

```

I can then have a different mapping for applicationY, which has different types.

```
{
  "logstash-applicationY-*" : {
    "mappings" : {
      "appY_type_*" : {
          # Mappings for ALL types for logstash-applicationY-*
       }
    }
  }
}

```

Does that make sense?

---

<div class="post-metadata">

**Author:** ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)\
**Post date:** [March 30, 2017, 1:09am UTC](https://discuss.elastic.co/t/how-to-use-the-same-mapping-for-all-similar-indices-and-then-for-all-types-in-the-index/80523/2 "2017-03-30T01:09:02Z")

</div>

Hi,

What about template?

[https://www.elastic.co/guide/en/elasticsearch/reference/5.3/indices-templates.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/indices-templates.html)

---

<div class="post-metadata">

**Author:** ![ZillaG](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zillag/32/10505_2.png) [@ZillaG](https://discuss.elastic.co/u/ZillaG)\
**Post date:** [March 30, 2017, 1:54pm UTC](https://discuss.elastic.co/t/how-to-use-the-same-mapping-for-all-similar-indices-and-then-for-all-types-in-the-index/80523/3 "2017-03-30T13:54:36Z")

</div>

@gabriel_tessier, thanks. I started reading about templates per your post. I have some questions. If I have this template...

```
{
  "template" : "logstash-appX-*",
  "mappings" : {
    "appX-type-*" : {
       # some mappings
    }
  }
}

```

What is the significance of the template name, logstash-appX-\* in this case. Does this mean that ALL indices that have the form ogstash-appX-_, e.g., logstash-appX-2017.03.29, logstash-appX-2017.03.30, will use this template? However, indices with logstash-appY-_ will NOT, and will need/want another template for those indices? IOW, in general, how do I associate an indices to a certain template?

Will the appX-type-\* mapping, with the \* in the name, apply to all types of that form, that is appX-type-0, appX-type-1, etc?

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:** [April 27, 2017, 1:54pm UTC](https://discuss.elastic.co/t/how-to-use-the-same-mapping-for-all-similar-indices-and-then-for-all-types-in-the-index/80523/4 "2017-04-27T13:54:46Z")

</div>

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