原英文版地址: https://www.elastic.co/guide/en/elasticsearch/reference/7.7/ingest-conditionals.html, 原文档版权归 www.elastic.co 所有
本地英文版地址: ../en/ingest-conditionals.html
本地英文版地址: ../en/ingest-conditionals.html
重要: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 当前版本文档。
Conditional Execution in Pipelinesedit
Each processor allows for an optional if
condition to determine if that
processor should be executed or skipped. The value of the if
is a
Painless script that needs to evaluate
to true
or false
.
For example the following processor will drop the document
(i.e. not index it) if the input document has a field named network_name
and it is equal to Guest
.
PUT _ingest/pipeline/drop_guests_network { "processors": [ { "drop": { "if": "ctx.network_name == 'Guest'" } } ] }
Using that pipeline for an index request:
POST test/_doc/1?pipeline=drop_guests_network { "network_name" : "Guest" }
Results in nothing indexed since the conditional evaluated to true
.
{ "_index": "test", "_type": "_doc", "_id": "1", "_version": -3, "result": "noop", "_shards": { "total": 0, "successful": 0, "failed": 0 } }