I have been trying to create an index which would not index any field if no dynamic/implicit template is defined for a field.
PUT http://localhost:9200/test1
{ "mappings": { "my_type": { "dynamic_templates": [ { "indexed": { "path_match": "indexed.*", "match_mapping_type": "string", "mapping": { "type": "keyword" } } }, { "others": { "path_match": "others.*", "match_mapping_type": "string", "mapping": { "enabled": false } } } ] } } }
As per the above setting the below document should get indexed, but it throws error:
POST http://localhost:9200/test1/my_type
{
"indexed": {
"a": "c"
},
"others": {
"somerandome": "qqqss",
"somerandome.www": "qqqss"
}
}
Error:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Can't merge a non object mapping [others.somerandome] with an object mapping [others.somerandome]"
}
],
"type": "illegal_argument_exception",
"reason": "Can't merge a non object mapping [others.somerandome] with an object mapping [others.somerandome]"
},
"status": 400
}
Also, looking at the code, it seems i can only use enabled:false for object type fields.
Also tried creating static template for a keyword type field as enabled:false and got error.
PUT http://localhost:9200/test2
{ "mappings": { "my_type": { "properties": { "others": { "type": "object", "properties": { "somerandome": { "type": "keyword", "enabled": false } } } } } } }
Error:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "Mapping definition for [somerandome] has unsupported parameters: [enabled : false]"
}
],
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [my_type]: Mapping definition for [somerandome] has unsupported parameters: [enabled : false]",
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "Mapping definition for [somerandome] has unsupported parameters: [enabled : false]"
}
},
"status": 400
}