# Mapping per index

**URL:** https://discuss.elastic.co/t/mapping-per-index/20573
**Category:** Elasticsearch
**Created:** [November 5, 2014, 4:41am UTC](https://discuss.elastic.co/t/mapping-per-index/20573 "2014-11-05T04:41:07Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Alejandro\_Alves](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alejandro_alves/32/1074_2.png) [@Alejandro\_Alves](https://discuss.elastic.co/u/Alejandro_Alves)
#### Post date: [November 5, 2014, 4:41am UTC](https://discuss.elastic.co/t/mapping-per-index/20573/1 "2014-11-05T04:41:07Z")

</div>

Hello,  
I want to have different indexes depending on the type, ie if the type is  
syslog, I want a syslog-logstash-DATE index. That is easy to achive then I  
want to have a mapping per index. That is have one template per index, is  
there a way to do that. I have tried something like this:

input {  
redis {  
host =\> "127.0.0.1"  
data\_type =\> "list"  
type =\> "redis-input"  
key =\> "logstash"  
}  
syslog {  
type =\> syslog  
port =\> 5514  
}  
}  
output {  
stdout { }  
elasticsearch {  
cluster =\> "logstash"  
index =\> "%{type}-logstash-%{+YYYY.MM.dd}"  
template =\> "/etc/logstash/conf.d/%{type}-template.json"  
}  
}

But it does not work, is there a way to do it, besides doing it manually?

Regards

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/c31a8b93-bc7b-47eb-afc1-83859f138660%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c31a8b93-bc7b-47eb-afc1-83859f138660%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [November 5, 2014, 4:55am UTC](https://discuss.elastic.co/t/mapping-per-index/20573/2 "2014-11-05T04:55:56Z")

</div>

The best way I can think of would be to use conditionals in your output,  
one per type, then you can directly point to specific templates for each  
type.

On 5 November 2014 15:41, Alejandro Alves [alejandro.alves@gmail.com](mailto:alejandro.alves@gmail.com) wrote:

> Hello,  
> I want to have different indexes depending on the type, ie if the type is  
> syslog, I want a syslog-logstash-DATE index. That is easy to achive then I  
> want to have a mapping per index. That is have one template per index, is  
> there a way to do that. I have tried something like this:
> 
> input {  
> redis {  
> host =\> "127.0.0.1"  
> data\_type =\> "list"  
> type =\> "redis-input"  
> key =\> "logstash"  
> }  
> syslog {  
> type =\> syslog  
> port =\> 5514  
> }  
> }  
> output {  
> stdout { }  
> elasticsearch {  
> cluster =\> "logstash"  
> index =\> "%{type}-logstash-%{+YYYY.MM.dd}"  
> template =\> "/etc/logstash/conf.d/%{type}-template.json"  
> }  
> }
> 
> But it does not work, is there a way to do it, besides doing it manually?
> 
> Regards
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/c31a8b93-bc7b-47eb-afc1-83859f138660%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c31a8b93-bc7b-47eb-afc1-83859f138660%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/c31a8b93-bc7b-47eb-afc1-83859f138660%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c31a8b93-bc7b-47eb-afc1-83859f138660%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAF3ZnZnUyGgqH%2BbvsENsO9B%3DqTccmskYSoYVkVaFEr8pctYXmQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAF3ZnZnUyGgqH%2BbvsENsO9B%3DqTccmskYSoYVkVaFEr8pctYXmQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Alejandro\_Alves](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alejandro_alves/32/1074_2.png) [@Alejandro\_Alves](https://discuss.elastic.co/u/Alejandro_Alves)
#### Post date: [November 5, 2014, 7:50pm UTC](https://discuss.elastic.co/t/mapping-per-index/20573/3 "2014-11-05T19:50:48Z")

</div>

Hello,  
Yes, I thought about that, but we wanted something more dynamic, so we do  
not have to register every type, so if we have a new logstash shipper with  
a new type, we do not have to do anything in the central logstash.  
Thanks!

El miércoles, 5 de noviembre de 2014 17:56:23 UTC+13, Mark Walkom escribió:

> The best way I can think of would be to use conditionals in your output,  
> one per type, then you can directly point to specific templates for each  
> type.
> 
> On 5 November 2014 15:41, Alejandro Alves \<[alejand...@gmail.com](mailto:alejand...@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > Hello,  
> > I want to have different indexes depending on the type, ie if the type is  
> > syslog, I want a syslog-logstash-DATE index. That is easy to achive then I  
> > want to have a mapping per index. That is have one template per index, is  
> > there a way to do that. I have tried something like this:
> > 
> > input {  
> > redis {  
> > host =\> "127.0.0.1"  
> > data\_type =\> "list"  
> > type =\> "redis-input"  
> > key =\> "logstash"  
> > }  
> > syslog {  
> > type =\> syslog  
> > port =\> 5514  
> > }  
> > }  
> > output {  
> > stdout { }  
> > elasticsearch {  
> > cluster =\> "logstash"  
> > index =\> "%{type}-logstash-%{+YYYY.MM.dd}"  
> > template =\> "/etc/logstash/conf.d/%{type}-template.json"  
> > }  
> > }
> > 
> > But it does not work, is there a way to do it, besides doing it manually?
> > 
> > Regards
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/c31a8b93-bc7b-47eb-afc1-83859f138660%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c31a8b93-bc7b-47eb-afc1-83859f138660%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/c31a8b93-bc7b-47eb-afc1-83859f138660%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c31a8b93-bc7b-47eb-afc1-83859f138660%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/6602e3cd-b7ee-4e8f-ad18-9174781e0877%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6602e3cd-b7ee-4e8f-ad18-9174781e0877%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Alejandro\_Alves](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alejandro_alves/32/1074_2.png) [@Alejandro\_Alves](https://discuss.elastic.co/u/Alejandro_Alves)
#### Post date: [December 2, 2014, 9:42pm UTC](https://discuss.elastic.co/t/mapping-per-index/20573/4 "2014-12-02T21:42:40Z")

</div>

I have created a pull request which creates this feature

> <https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/25>
>
> Added the possiblity to use dinamyc templates. For example:
> 
> \`\`\`
> elasticsear…ch {
> cluster =\> "logstash"
> index =\> "%{type}-logstash-%{+YYYY.MM.dd}"
> template =\> "/etc/logstash/conf.d/%{type}-template.json"
> template\_name =\> "%{type}"
> }
> \`\`\`
> 
> It will also allow to parametrize the template. For example:
> 
> \`\`\`
> {
> "template": "%{type}-",
> "settings": {
> "number\_of\_shards" : 5,
> "index.cache.field.type" : "soft",
> "index.refresh\_interval" : "2s",
> "index.store.compress.stored" : true,
> "index.query.default\_field" : "@message"
> },
> .......
> }
> \`\`\`

El miércoles, 5 de noviembre de 2014 17:41:07 UTC+13, Alejandro Alves  
escribió:

> Hello,  
> I want to have different indexes depending on the type, ie if the type is  
> syslog, I want a syslog-logstash-DATE index. That is easy to achive then I  
> want to have a mapping per index. That is have one template per index, is  
> there a way to do that. I have tried something like this:
> 
> input {  
> redis {  
> host =\> "127.0.0.1"  
> data\_type =\> "list"  
> type =\> "redis-input"  
> key =\> "logstash"  
> }  
> syslog {  
> type =\> syslog  
> port =\> 5514  
> }  
> }  
> output {  
> stdout { }  
> elasticsearch {  
> cluster =\> "logstash"  
> index =\> "%{type}-logstash-%{+YYYY.MM.dd}"  
> template =\> "/etc/logstash/conf.d/%{type}-template.json"  
> }  
> }
> 
> But it does not work, is there a way to do it, besides doing it manually?
> 
> Regards

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/6a4cc76e-527a-43b7-8518-5f57972b4b05%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6a4cc76e-527a-43b7-8518-5f57972b4b05%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:46am UTC](https://discuss.elastic.co/t/mapping-per-index/20573/5 "2017-07-06T00:46:27Z")

</div>


