Elasticsearch 1.7: specify multiple index template patterns?


#1

I want to use the same template to specify mappings for indices with different patterns. Must I create a separate template file for each one? Attempts to specify more than one pattern have met with failure:

Approach 1
This does not seem to match either pattern1 or pattern2:

{ ...
   "template": "pattern1*|pattern2*"
   ...}
{code}

Approach 2
This seems to take the last "template" that was specified.

{ ...
  "template": "pattern1",
   "template":"pattern2"
   ...
}

Approach 3
This surprisingly seems to take the last item in the list and ignores the first:

{ ...
  "template": [ "pattern1*", "pattern2*" ]
 ... }

Is there a way to do this?


(Jeferson Martins) #2

In my case, I use only one template with:
template: "*"
and specify the order of "execution"


#3

Can you give a simple example? Are you saying you just have various types not used across multiple indices in the same file?

{... "template": "*" ...
      "type1" : { ... }
      "type2" : {... }
 ...}

(Jeferson Martins) #4

You want specify diferents schemas in same template?

I dont understand your example with type1 and type2.

In my case, I use the same schema for all indices. It is that you want?


#5

I have different types which may have different fields, so index1 may have different fields than index2. So I think my use case could be a little different than the one you've described.


#6

Does anyone have a different thought on this?


(Jeferson Martins) #7

Now I think if you have diferent types make sense have diferent templates.

There's the attribute order that you can specify that template will be use first


(system) #8