在我的索引“process”中,我有一个类型“logs”。对于这种类型的,我有这样的mappping:部分动态映射
{
"process": {
"mappings": {
"logs": {
"properties": {
"channel": {
"type": "string"
},
"context": {
"type": "object"
},
"datetime": {
"type": "date",
"format": "dateOptionalTime"
},
"extra": {
"type": "object"
"level": {
"type": "long"
},
"level_name": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
的事情是,在“背景”属性和“额外”的属性是动态的领域,每个文档都可以有不同数量不同的额外&上下文子元素名。 当我设置这个映射,然后我检查http://localhost:9200/process/_mapping/logs
,我看到这个非常映射。所以它的工作。此外,设置的答案是{acknowledge: true}
。到现在为止还挺好。
然后,我添加了几个文件,或者至少我尝试。第一个文件改变ES映射!
新的映射是:
{
"process" : {
"mappings" : {
"logs" : {
"properties" : {
"channel" : {
"type" : "string"
},
"context" : {
"properties" : {
"columns" : {
"type" : "string"
},
"count" : {
"type" : "long"
},
"errorMessage" : {
"type" : "string"
},
"serviice" : {
"type" : "string"
}
}
},
"datetime" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"extra" : {
"properties" : {
"uid" : {
"type" : "string"
}
}
},
"level" : {
"type" : "long"
},
"level_name" : {
"type" : "string"
},
"message" : {
"type" : "string"
}
}
}
}
}
}
当我尝试添加一个新的文档,它不符合这个新的映射,并触发此错误:
MapperParsingException[object mapping [context] trying to serialize a value with no field associated with it, current value [pid]]
所以我很清楚遗漏了什么。
- 为什么我的映射被覆盖?我试图删除整个索引,并从头开始构建一切,同样的行为。
- 是我想实现的可能吗?还是我有错误的方法?
编辑:被插入,似乎更新映射文件:
{
"message": "Starting background process `{service}`, registered under the ID ",
"context": {
"id": null,
"serviice": "fiduceo.import"
},
"level": 250,
"level_name": "NOTICE",
"channel": "process",
"datetime": "2016-06-09T11:23:42.304859+02:00",
"extra": {
"uid": "d1cb925"
}
}
,谁失败了一句:
{
"message": "Background process created (pid: {pid})",
"context": [
"pid",
18871
],
"level": 250,
"level_name": "NOTICE",
"channel": "process",
"datetime": "2016-06-09T11:23:41.519456+02:00",
"extra": {
"uid": "09fe183"
}
}
1.我不会说你的映射被覆盖,但更新。这意味着所有定义的字段保持原样,并且添加缺少的字段(不在映射中但在文档中)。 2.你想实现的目标一般是可能的,但是你与字段映射和JSON输入有一些冲突。请提供您的JSON文档,该文档对于此映射而言失败。 – Hansa