Why the dynamic_templates dose not work?


(zhouxiang) #1

my config
{
"data" : {
"analysis" : {
"analyzer" : {
"ik" : {
"type" :
"org.elasticsearch.index.analysis.IkAnalyzerProvider"
}
}
},
"ad" : {
"_all" : {"enabled" : false},
"_id" : {"path" : "id"},
"_timestamp" : {"enabled" : false},
"_source" : {"enabled" : false},
"properties" : {
"id" : {"type" : "long", "index" : "yes", "store" :
"yes"},
"title" : {"type" : "string", "store" : "no",
"indexAnalyzer" : "ik", "searchAnalyzer" : "ik", "include_in_all" :
"false"},
"description" : {"type" : "string", "store" : "no",
"indexAnalyzer" : "ik", "searchAnalyzer" : "ik", "include_in_all" :
"false"}
},
"dynamic_templates" : [
{
"templates_1" : {
"match" : "*_i",
"mapping" : {
"type" : "long",
"index" : "yes",
"store" : "no",
}
}
},
{
"templates_2" : {
"match" : "*Date",
"mapping" : {
"type" : "Date",
"index" : "yes",
"store" : "no",
"format" : "basic_date_time_no_millis",
}
}
},
{
"templates_3" : {
"match" : "*Time",
"mapping" : {
"type" : "Date",
"index" : "yes",
"store" : "no",
"format" : "basic_date_time_no_millis",
}
}
},
{
"templates_4" : {
"match" : "Position",
"mapping" : {
"type" : "geo_point",
"index" : "yes",
"store" : "no",
}
}
},
{
"templates_5" : {
"match" : "
",
"mapping" : {
"type" : "string",
"index" : "no",
"store" : "no",
}
}
},
]
}
}
}

when i add a doc under data/ad?but the dynamic templates dose not work.


(Shay Banon) #2

You need to place the dynamic templates in the mapping definition, not the
index settings. You can place it under a default mapping name to apply to
all mappings. Thats why the config is under the root mapping type:
http://www.elasticsearch.org/guide/reference/mapping/root-object-type.html.

On Mon, Mar 26, 2012 at 10:09 AM, shinezhou zhouxiang@baixing.com wrote:

my config
{
"data" : {
"analysis" : {
"analyzer" : {
"ik" : {
"type" :
"org.elasticsearch.index.analysis.IkAnalyzerProvider"
}
}
},
"ad" : {
"_all" : {"enabled" : false},
"_id" : {"path" : "id"},
"_timestamp" : {"enabled" : false},
"_source" : {"enabled" : false},
"properties" : {
"id" : {"type" : "long", "index" : "yes", "store" :
"yes"},
"title" : {"type" : "string", "store" : "no",
"indexAnalyzer" : "ik", "searchAnalyzer" : "ik", "include_in_all" :
"false"},
"description" : {"type" : "string", "store" : "no",
"indexAnalyzer" : "ik", "searchAnalyzer" : "ik", "include_in_all" :
"false"}
},
"dynamic_templates" : [
{
"templates_1" : {
"match" : "*_i",
"mapping" : {
"type" : "long",
"index" : "yes",
"store" : "no",
}
}
},
{
"templates_2" : {
"match" : "*Date",
"mapping" : {
"type" : "Date",
"index" : "yes",
"store" : "no",
"format" : "basic_date_time_no_millis",
}
}
},
{
"templates_3" : {
"match" : "*Time",
"mapping" : {
"type" : "Date",
"index" : "yes",
"store" : "no",
"format" : "basic_date_time_no_millis",
}
}
},
{
"templates_4" : {
"match" : "Position",
"mapping" : {
"type" : "geo_point",
"index" : "yes",
"store" : "no",
}
}
},
{
"templates_5" : {
"match" : "
",
"mapping" : {
"type" : "string",
"index" : "no",
"store" : "no",
}
}
},
]
}
}
}

when i add a doc under data/ad?but the dynamic templates dose not work.


(system) #3