Default mapping confusion

Hi all

I have read through the documentation, but am slightly confused by the
topic of default mapping.

Is there a difference between defining config/mappings/_default/
mapping.json as described here[1] and defining config/default-
mapping.json as described here[2]?

Many thanks
Greg

[1] http://www.elasticsearch.org/guide/reference/mapping/conf-mappings.html
[2] http://www.elasticsearch.org/guide/reference/mapping/dynamic-mapping.html

[2] gets applied to all mappings, ever. [1] is for all indices, but the name of the file is the name of the type.

In any case, the new(er) index templates and dynamic templates are preferred.
On Friday, May 13, 2011 at 6:57 PM, Greg wrote:

Hi all

I have read through the documentation, but am slightly confused by the
topic of default mapping.

Is there a difference between defining config/mappings/_default/
mapping.json as described here[1] and defining config/default-
mapping.json as described here[2]?

Many thanks
Greg

[1] Elasticsearch Platform — Find real-time answers at scale | Elastic
[2] Elasticsearch Platform — Find real-time answers at scale | Elastic

Hi Shay

Thanks for clarifying this.

I currently use the following in config/default-mapping.json to
disable the _source field and string analyzing across all indexes and
types:

{
"default" : {
"_source" : { "enabled" : false },
"dynamic_templates" : [
{
"disable_string_analyzing" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
]
}
}

I am trying to convert this to the newer index templates format, with
little success:

{
"template" : "",
"mappings" : {
"
" : {
"_source" : { "enabled" : false }
}
},
"dynamic_templates" : [
{
"disable_string_analyzing" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
],
}

What am I doing wrong?

Many thanks
Greg

Its perfectly fine to use the config/default-mapping. If you use the index template, did you use the API to "put" it?
On Sunday, May 15, 2011 at 3:57 PM, Greg wrote:

Hi Shay

Thanks for clarifying this.

I currently use the following in config/default-mapping.json to
disable the _source field and string analyzing across all indexes and
types:

{
"default" : {
"_source" : { "enabled" : false },
"dynamic_templates" : [
{
"disable_string_analyzing" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
]
}
}

I am trying to convert this to the newer index templates format, with
little success:

{
"template" : "",
"mappings" : {
"
" : {
"_source" : { "enabled" : false }
}
},
"dynamic_templates" : [
{
"disable_string_analyzing" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
],
}

What am I doing wrong?

Many thanks
Greg

Yes, I PUT it to http://localhost:9200/_template/template_1.

When I GET the above address, I see:

{
"template_1" : {
"template" : "",
"order" : 0,
"settings" : {
},
"mappings" : {
"
" : {
"_source" : {
"enabled" : false
},
"dynamic_templates" : [ {
"disable_string_analyzing" : {
"mapping" : {
"index" : "not_analyzed",
"type" : "string"
},
"match" : "*",
"match_mapping_type" : "string"
}
} ]
}
}
}
}

However, when I create a new index, it still has the _source field and
the string fields are being tokenized, so the template doesn't appear
to be getting applied.

If it is perfectly fine to use config/default-mapping.json, I may as
well continue using this. I was just concerned because you said there
was a newer method that the old method might become deprecated.

Haven't run it, but the mapping you define are wrong, there is no support for "*" as the mapping type. There is support for setting the it to default.
On Sunday, May 15, 2011 at 5:50 PM, Greg wrote:

Yes, I PUT it to http://localhost:9200/_template/template_1.

When I GET the above address, I see:

{
"template_1" : {
"template" : "",
"order" : 0,
"settings" : {
},
"mappings" : {
"
" : {
"_source" : {
"enabled" : false
},
"dynamic_templates" : [ {
"disable_string_analyzing" : {
"mapping" : {
"index" : "not_analyzed",
"type" : "string"
},
"match" : "*",
"match_mapping_type" : "string"
}
} ]
}
}
}
}

However, when I create a new index, it still has the _source field and
the string fields are being tokenized, so the template doesn't appear
to be getting applied.

If it is perfectly fine to use config/default-mapping.json, I may as
well continue using this. I was just concerned because you said there
was a newer method that the old method might become deprecated.

Thanks Shay, it is working now using "default" instead of "*".