The If Wrapper stage in SearchAPI allows you to execute a list of stages based on the result of a comparison. This stage checks a specific field inside the intermediate data and compares its value with the one provided in the check_value parameter. If the comparison is true, the stages specified in the stages parameter will be executed. Alternatively, if the else_stages parameter is provided, those stages will be executed.
This applies for all the stage functions process, post_process and get_ui_config
Remember that the intermediate can be fill with either other stages or the original request body that trigger the pipeline, making this essentially REST API parameters
If Wrapper doesn't return value to the pipeline
Property | Description | Default | Type | Required |
---|---|---|---|---|
type | Stage class name | - | string | Yes |
enable | Enable stage for execution | true | boolean | No |
name | Name for this specific stage | "if" | string | No |
save_to_intermediate | If true, the result of the stage will be stored in the intermediate instead of the final section | false | boolean | No |
ui_only | Section specific for UI configuration that affects the process of the stage | object | No | |
halt_on_exception | Indicates if the pipeline should be interrupted in case of an exception | false | boolean | No |
stages | Pipeline with stages to be executed if the condition is true | - | Pipeline, PipelineLoop | Yes (minItems: 1) |
else_stages | Pipeline with stages to be executed if the condition is false | [] | Pipeline, PipelineLoop | No (minItems: 1) |
check_field | Name of the field look for it's value in the intermediate | - | string | Yes |
check_value | Field value used to compare with the value in the "check_field" to determine if the stage should be enabled | - | Any | No |
_if = IfWrapperStage( name='if', check_field='flag', check_value=True, stages=Pipeline(stages=[_search1]), else_stages=Pipeline(stages=[_search1]) )