原英文版地址: https://www.elastic.co/guide/en/elasticsearch/reference/7.7/conditionals-with-multiple-pipelines.html, 原文档版权归 www.elastic.co 所有
本地英文版地址: ../en/conditionals-with-multiple-pipelines.html
本地英文版地址: ../en/conditionals-with-multiple-pipelines.html
重要: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 当前版本文档。
Conditionals with the Pipeline Processoredit
The combination of the if
conditional and the Pipeline Processor can result in a simple,
yet powerful means to process heterogeneous input. For example, you can define a single pipeline
that delegates to other pipelines based on some criteria.
PUT _ingest/pipeline/logs_pipeline { "description": "A pipeline of pipelines for log files", "version": 1, "processors": [ { "pipeline": { "if": "ctx.service?.name == 'apache_httpd'", "name": "httpd_pipeline" } }, { "pipeline": { "if": "ctx.service?.name == 'syslog'", "name": "syslog_pipeline" } }, { "fail": { "if": "ctx.service?.name != 'apache_httpd' && ctx.service?.name != 'syslog'", "message": "This pipeline requires service.name to be either `syslog` or `apache_httpd`" } } ] }
The above example allows consumers to point to a single pipeline for all log based index requests. Based on the conditional, the correct pipeline will be called to process that type of data.
This pattern works well with a default pipeline defined in an index mapping template for all indexes that hold data that needs pre-index processing.