在我的索引“进程”中,我有一个类型“logs”。对于这种类型,我有这个映射:
http://localhost:9200/process/_mapping/logs
问题是,“context”属性和“extra”属性是动态字段,每个文档可以有不同数量的额外& context子元素名称不同。
当我设置此映射,然后检查{acknowledge: true}
时,我看到了这个映射。所以它奏效了。此设置的答案还是{
"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"
}
}
}
}
}
}
。到目前为止一切都很好。
然后,我添加了几个文件,或者至少我尝试了。第一个文档改变了ES映射!
新映射是:
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"
}
}
失败者:
var json = {};
var id = "test";
eval("json." + id + " = 5;");
console.log(json.test);
答案 0 :(得分:1)
您的上下文字段包含无效的JSON
它应该如下所示:
"context": {
"pid": 18871
},
与您的版本相比:
"context": [
"pid",
18871
]
编辑:为了给出完整的答案(并重复评论中所写的内容):