情况: 我将“on_failure”语句设置为现有管道,如下所示(对于整个管道):
"on_failure" : [
{
"set" : {
"field" : "_index",
"value" : "failed-{{ _index }}"
}
},
{
"set" : {
"field" : "caused_by",
"value" : "{{ _ingest.on_failure_message }}"
}
}
]
问题: 管道与 update_by_query API 一起使用以丰富文档。在失败的情况下,管道不会将失败的文档转发到失败的索引,即。失败-my_index。这是由于以下错误消息造成的:
{
"took": 276,
"timed_out": false,
"total": 1,
"updated": 0,
"deleted": 0,
"batches": 1,
"version_conflicts": 1,
"noops": 0,
"retries": {
"bulk": 0,
"search": 0
},
"throttled_millis": 0,
"requests_per_second": -1,
"throttled_until_millis": 0,
"failures": [
{
"index": "failed-my_index",
"type": "_doc",
"id": "1002109",
"cause": {
"type": "version_conflict_engine_exception",
"reason": "[1002109]: version conflict, required seqNo [37265539], primary term [20]. but no document was found",
"index_uuid": "JMepgCegQamU8WDqQuFJ3Q",
"shard": "0",
"index": "failed-my_index"
},
"status": 409
}
]
}
这是真的,因为失败的索引中不存在文档“1002109”,因为它最初索引时并没有失败。 更新时,管道失败,文档需要进入失败的索引。由于上述版本冲突错误,这不会发生。
我在这里做错了什么?
感谢任何帮助
答案 0 :(得分:1)
如关于 _update_by_query
端点的 official documentation 所述:
此 API 只能让您修改匹配文档的来源,您不能移动它们。
脚本文档中也提供了有关 the update by query context 中可以做什么的信息,因为我们可以看到大多数 ctx._*
字段是只读的:
因此,不可能使用按查询更新来更改文档的索引。但是,您可以标记文档,然后使用重新索引 + 按查询删除的组合将这些标记的文档移动到失败的索引中。