Skip to content

Commit 1fcfb84

Browse files
original-brownbearkcm
authored andcommitted
INGEST: Document Processor Conditional (#33388)
* INGEST: Document Processor Conditional Relates #33188
1 parent 3e1c17f commit 1fcfb84

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

docs/reference/ingest/ingest-node.asciidoc

+19-1
Original file line numberDiff line numberDiff line change
@@ -721,12 +721,30 @@ All processors are defined in the following way within a pipeline definition:
721721
// NOTCONSOLE
722722

723723
Each processor defines its own configuration parameters, but all processors have
724-
the ability to declare `tag` and `on_failure` fields. These fields are optional.
724+
the ability to declare `tag`, `on_failure` and `if` fields. These fields are optional.
725725

726726
A `tag` is simply a string identifier of the specific instantiation of a certain
727727
processor in a pipeline. The `tag` field does not affect the processor's behavior,
728728
but is very useful for bookkeeping and tracing errors to specific processors.
729729

730+
The `if` field must contain a script that returns a boolean value. If the script evaluates to `true`
731+
then the processor will be executed for the given document otherwise it will be skipped.
732+
The `if` field takes an object with the script fields defined in <<script-processor, script-options>>
733+
and accesses a read only version of the document via the same `ctx` variable used by scripts in the
734+
<<script-processor>>.
735+
736+
[source,js]
737+
--------------------------------------------------
738+
{
739+
"set": {
740+
"if": "ctx.bar == 'expectedValue'",
741+
"field": "foo",
742+
"value": "bar"
743+
}
744+
}
745+
--------------------------------------------------
746+
// NOTCONSOLE
747+
730748
See <<handling-failure-in-pipelines>> to learn more about the `on_failure` field and error handling in pipelines.
731749

732750
The <<ingest-info,node info API>> can be used to figure out what processors are available in a cluster.

0 commit comments

Comments
 (0)