Several matching dynamic_templates?

Is it possible to somehow configure dynamic_templates so that multiple
matching templates will be applied? It seems to me that only the first
matching template is used. I can see why that is, but if there's a
workaround I'd love to know about it :slight_smile:

As an example, I'm using something like the dynamic templates below
and would like strings to be mapped both as multifield and as not
included in all IF their names end with "!inall".

{
"string_template":{
"match":"",
"match_mapping_type":"string",
"mapping":{
"type":"multi_field",
"fields":{
"{name}":{
"type":"string",
"index":"not_analyzed"
},
"standard":{
"type":"string"
}
}
}
}
},
{
"not_in_all_template":{
"match":"
!inall",
"mapping":{
"include_in_all":false
}
}
},

Hi Joel,

Multiple matching templates are supported by ES (see the end of
Elasticsearch Platform — Find real-time answers at scale | Elastic).
It looks like you don't have a parallel structure between your two
mappings, though -- did you intend to put the 'include_in_all' key
inside a field definition?

Mat

On Sun, Jul 31, 2011 at 10:16, Joel Abrahamsson
mail@joelabrahamsson.com wrote:

Is it possible to somehow configure dynamic_templates so that multiple
matching templates will be applied? It seems to me that only the first
matching template is used. I can see why that is, but if there's a
workaround I'd love to know about it :slight_smile:

As an example, I'm using something like the dynamic templates below
and would like strings to be mapped both as multifield and as not
included in all IF their names end with "!inall".

{
"string_template":{
"match":"",
"match_mapping_type":"string",
"mapping":{
"type":"multi_field",
"fields":{
"{name}":{
"type":"string",
"index":"not_analyzed"
},
"standard":{
"type":"string"
}
}
}
}
},
{
"not_in_all_template":{
"match":"
!inall",
"mapping":{
"include_in_all":false
}
}
},

Hey!

Thanks for the reply!

I'm not sure what you mean by parallel structure? The last template is
applied if I remove the first, otherwise the first but not the second
is applied.

I should probably add that I'm using these for the default type in a
default-mapping.json file.

/Joel

On 31 Juli, 16:23, "Matthew A. Brown" mat.a.br...@gmail.com wrote:

Hi Joel,

Multiple matching templates are supported by ES (see the end ofhttp://www.elasticsearch.org/guide/reference/api/admin-indices-templa...).
It looks like you don't have a parallel structure between your two
mappings, though -- did you intend to put the 'include_in_all' key
inside a field definition?

Mat

On Sun, Jul 31, 2011 at 10:16, Joel Abrahamsson

m...@joelabrahamsson.com wrote:

Is it possible to somehow configure dynamic_templates so that multiple
matching templates will be applied? It seems to me that only the first
matching template is used. I can see why that is, but if there's a
workaround I'd love to know about it :slight_smile:

As an example, I'm using something like the dynamic templates below
and would like strings to be mapped both as multifield and as not
included in all IF their names end with "!inall".

{
"string_template":{
"match":"",
"match_mapping_type":"string",
"mapping":{
"type":"multi_field",
"fields":{
"{name}":{
"type":"string",
"index":"not_analyzed"
},
"standard":{
"type":"string"
}
}
}
}
},
{
"not_in_all_template":{
"match":"
!inall",
"mapping":{
"include_in_all":false
}
}
},

Oh, actually it seems we we're talking about different things. I'm not
talking about index templates by dynamic templates for types/
properties :slight_smile:

On 31 Juli, 16:23, "Matthew A. Brown" mat.a.br...@gmail.com wrote:

Hi Joel,

Multiple matching templates are supported by ES (see the end ofhttp://www.elasticsearch.org/guide/reference/api/admin-indices-templa...).
It looks like you don't have a parallel structure between your two
mappings, though -- did you intend to put the 'include_in_all' key
inside a field definition?

Mat

On Sun, Jul 31, 2011 at 10:16, Joel Abrahamsson

m...@joelabrahamsson.com wrote:

Is it possible to somehow configure dynamic_templates so that multiple
matching templates will be applied? It seems to me that only the first
matching template is used. I can see why that is, but if there's a
workaround I'd love to know about it :slight_smile:

As an example, I'm using something like the dynamic templates below
and would like strings to be mapped both as multifield and as not
included in all IF their names end with "!inall".

{
"string_template":{
"match":"",
"match_mapping_type":"string",
"mapping":{
"type":"multi_field",
"fields":{
"{name}":{
"type":"string",
"index":"not_analyzed"
},
"standard":{
"type":"string"
}
}
}
}
},
{
"not_in_all_template":{
"match":"
!inall",
"mapping":{
"include_in_all":false
}
}
},

There isn't support in dynamic templates to "aggregate templates", the first
one matches (ordered) will be used, so you need to provide full mapping on
relevant ones. Its a bit tricky (at least in the way its implemented
currently) to apply everything the matches to the new field mapping
introduced.

On Sun, Jul 31, 2011 at 6:00 PM, Joel Abrahamsson
mail@joelabrahamsson.comwrote:

Oh, actually it seems we we're talking about different things. I'm not
talking about index templates by dynamic templates for types/
properties :slight_smile:

On 31 Juli, 16:23, "Matthew A. Brown" mat.a.br...@gmail.com wrote:

Hi Joel,

Multiple matching templates are supported by ES (see the end ofhttp://
Elasticsearch Platform — Find real-time answers at scale | Elastic...).
It looks like you don't have a parallel structure between your two
mappings, though -- did you intend to put the 'include_in_all' key
inside a field definition?

Mat

On Sun, Jul 31, 2011 at 10:16, Joel Abrahamsson

m...@joelabrahamsson.com wrote:

Is it possible to somehow configure dynamic_templates so that multiple
matching templates will be applied? It seems to me that only the first
matching template is used. I can see why that is, but if there's a
workaround I'd love to know about it :slight_smile:

As an example, I'm using something like the dynamic templates below
and would like strings to be mapped both as multifield and as not
included in all IF their names end with "!inall".

{
"string_template":{
"match":"",
"match_mapping_type":"string",
"mapping":{
"type":"multi_field",
"fields":{
"{name}":{
"type":"string",
"index":"not_analyzed"
},
"standard":{
"type":"string"
}
}
}
}
},
{
"not_in_all_template":{
"match":"
!inall",
"mapping":{
"include_in_all":false
}
}
},

I see, thanks!

2011/7/31 Shay Banon kimchy@gmail.com

There isn't support in dynamic templates to "aggregate templates", the
first one matches (ordered) will be used, so you need to provide full
mapping on relevant ones. Its a bit tricky (at least in the way its
implemented currently) to apply everything the matches to the new field
mapping introduced.

On Sun, Jul 31, 2011 at 6:00 PM, Joel Abrahamsson <
mail@joelabrahamsson.com> wrote:

Oh, actually it seems we we're talking about different things. I'm not
talking about index templates by dynamic templates for types/
properties :slight_smile:

On 31 Juli, 16:23, "Matthew A. Brown" mat.a.br...@gmail.com wrote:

Hi Joel,

Multiple matching templates are supported by ES (see the end ofhttp://
Elasticsearch Platform — Find real-time answers at scale | Elastic...).
It looks like you don't have a parallel structure between your two
mappings, though -- did you intend to put the 'include_in_all' key
inside a field definition?

Mat

On Sun, Jul 31, 2011 at 10:16, Joel Abrahamsson

m...@joelabrahamsson.com wrote:

Is it possible to somehow configure dynamic_templates so that multiple
matching templates will be applied? It seems to me that only the first
matching template is used. I can see why that is, but if there's a
workaround I'd love to know about it :slight_smile:

As an example, I'm using something like the dynamic templates below
and would like strings to be mapped both as multifield and as not
included in all IF their names end with "!inall".

{
"string_template":{
"match":"",
"match_mapping_type":"string",
"mapping":{
"type":"multi_field",
"fields":{
"{name}":{
"type":"string",
"index":"not_analyzed"
},
"standard":{
"type":"string"
}
}
}
}
},
{
"not_in_all_template":{
"match":"
!inall",
"mapping":{
"include_in_all":false
}
}
},