例如,我想为书籍和文件制作映射。这些书籍和文件有共同的标题字段,但之后是不同的字段。因此,我制作了动态模板(进行此映射的主要原因是让某些字符串字段设置为关键字,而不是文本)。
PUT my_index
{
"mappings" : {
"my_type" : {
"properties" : {
"title" : {
"type" : "keyword"
},
"props" : {
"dynamic" : true,
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"type": "keyword"
}
}
}
]
}
}
}
}
}
我这样做了,但随之而来的错误。
"reason": "Failed to parse mapping [my_type]: No type specified for field [props]",
对此有什么想法吗?
最佳答案
动态模板是类型的根,请参阅 the link
你应该有这样的东西
{
"mappings": {
"my_type": {
"properties": {
"title": {
"type": "keyword"
}
},
"dynamic_templates": [
{
"strings": {
"path_match": "props.*",
"match_mapping_type": "string",
"mapping": {
"type": "keyword"
}
}
}
]
}
}
}
关于Elasticsearch - 动态字段模板映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43646701/