Reputation: 3053
For example, I would like to make mapping for books and files. These books and files have common title field, but they are different field after that. So, I made dynamic templates (main reason to make this mapping is to let some string field set as keyword, not text).
PUT my_index
{
"mappings" : {
"my_type" : {
"properties" : {
"title" : {
"type" : "keyword"
},
"props" : {
"dynamic" : true,
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"type": "keyword"
}
}
}
]
}
}
}
}
}
I made like this but error comes with this.
"reason": "Failed to parse mapping [my_type]: No type specified for field [props]",
Any idea of this?
Upvotes: 2
Views: 1593
Reputation: 19514
Dynamic template is root of type see the link
You should have smth like this
{
"mappings": {
"my_type": {
"properties": {
"title": {
"type": "keyword"
}
},
"dynamic_templates": [
{
"strings": {
"path_match": "props.*",
"match_mapping_type": "string",
"mapping": {
"type": "keyword"
}
}
}
]
}
}
}
Upvotes: 4