How to apply different index template in single index?

Hi!

I am using logstash (ver 5.0.0 alpha 4) to insert data into elasticsearch.

I would like to know whether it is possible to apply different index template according to type name but in same index.

https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html

So for example,

Logstash inserts documents as below types. All type has common fields and field types.

Index type fields and type
idx1 apple field : keyword
idx1 orange field : keyword
idx1 banana field : keyword

Is it possible to create different index templates?

You can define multiple search types for a single index, see https://www.elastic.co/guide/en/elasticsearch/guide/current/multi-index-multi-type.html

Hi !

Sorry I didnt make my explanation clear.

I was mentioning about index template.

https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html

There is no way, because index template is applied only at index creation time.
It is not related type name.

However you can create different index templates.
Multi index templates can be applied to one index.
https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html#multiple-templates

Hello Jun-san.

What I thought was since you specify type , elasticsearch will also use the type for matching template.

I should have read definitive guide.

https://www.elastic.co/guide/en/elasticsearch/guide/2.x/mapping.html

I cannot have same field name with different type anyway.

Be careful of this - https://www.elastic.co/blog/index-vs-type

@warkolm

Thank you for the reply.

I will look into it.