【发布时间】:2017-10-24 10:51:57
【问题描述】:
我目前使用的摄取节点管道如下所示:
{
"my-pipeline": {
"description": "pipeline for my filebeat",
"processors": [
{
"json": {
"field": "message",
"add_to_root": true,
"on_failure": [
{
"rename": {
"field": "message",
"target_field": "originalMessage",
"ignore_missing": true
}
},
{
"set": {
"field": "indexName",
"value": "pipeline-errors"
}
},
{
"set": {
"field": "indexType",
"value": "pipeline-error"
}
},
{
"rename": {
"field": "@timestamp",
"target_field": "errorTimestamp",
"ignore_missing": true
}
}
]
}
},
{
"remove": {
"field": "@timestamp",
"ignore_failure": true
}
},
{
"remove": {
"field": "message",
"ignore_failure": true
}
},
{
"script": {
"inline": "ctx._index = ctx.indexName; ctx._type=ctx.indexType; if (ctx.docVersion != null) {ctx._version = ctx.docVersion; ctx._version_type='external'}"
}
},
{
"remove": {
"field": "indexName",
"ignore_failure": true
}
},
{
"remove": {
"field": "indexType",
"ignore_failure": true
}
}
]
}
}
此管道用于简单地将由 filebeat 转发的日志拆箱。在脚本处理器中,我查找“indexName”和“indexType”字段并将其分别分配给“_index”和“_type”。由于我需要考虑版本,因此日志中包含“版本”字段(但这是可选的,因为某些日志不包含版本)。
使用此管道触发器:
org.elasticsearch.index.mapper.MapperParsingException: Cannot generate dynamic mappings of type [_version] for [_version]
at org.elasticsearch.index.mapper.DocumentParser.createBuilderFromFieldType(DocumentParser.java:656) ~[elasticsearch-5.5.0.jar:5.5.0]
at org.elasticsearch.index.mapper.DocumentParser.parseDynamicValue(DocumentParser.java:805) ~[elasticsearch-5.5.0.jar:5.5.0]
到目前为止我所尝试的(09-16 更新):
- 将字段名称替换为“docVersion”之类的名称 如果它是关键字,请确保它不会发生冲突。这不起作用 太
- 尝试使用 ctx._source.version,这会触发 ScriptException[运行时错误];毕竟,请注意 _index 和 _type 值分别来自 ctx.indexName 和 ctx.indexType
- 也尝试在脚本上添加 'version_type=external';我仍然收到上述 MapperParsingException;
- 尝试使用 'version_type=external_gte' 但我也遇到了 MapperParsingException
在使用 ingester 节点管道时,如何在 elasticsearch 文档中指定/使用外部版本控制?如果通过管道的脚本处理器无法做到这一点,那么在使用 filebeat-to-elasticsearch 时,有哪些选项可以使用外部版本,从而拒绝旧版本的文档?
2017 年 10 月 24 日更新 似乎这是当前弹性搜索版本(在我的情况下为 5.6)不存在的功能。根据code 中的检查,管道执行服务中的 IndexRequest 不包含对文档版本或版本类型的任何引用,因此默认为内部版本。也许这可以作为未来弹性搜索版本中的一项功能添加。
【问题讨论】:
标签: elasticsearch