In this article
Table of Contents |
---|
Overview
The Filter Snap
...
filters a document stream based on an expression. If the filter expression evaluates to true, then the document will be passed-through. If the filter expression evaluates to false, then the document will be dropped in the stream. Expressions that do not evaluate to a boolean value will cause the pipeline to fail. Learn more about Expression functions.
...
Info |
---|
|
Snap Type
The Filter Snap is a Flow-type Snap.
Support for Ultra Pipelines
Works in Ultra Pipelines.
Info |
---|
When using the Filter Snap in an ultra pipeline, the pipeline returns an empty response if the Snap filters the incoming document. |
Snap Views
Type | Format | Number of Views | Examples of Upstream and Downstream Snaps | Description |
---|
...
Input | Document | Min: |
...
1 Max: |
...
1 | JSON Generator | The data in the input document to filter. |
Output | Document | Min: |
...
1 Max: |
...
1 |
| The filtered document. | ||
Error | Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter when running the pipeline by choosing one of the following options from the When errors occur list under the Views tab:
Learn more about Error handling in Pipelines. |
Snap Settings
Field | Field Type | Description | |
---|---|---|---|
Label*
| String | The name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your pipeline. | |
Null-safe access Default Value: Deselected | Checkbox | Select this checkbox to consider the missing data or empty value as null when accessing the source path. If you deselect this checkbox, the Snap fails and displays error in case there is missing data or empty value when accessing the source path. | |
Filter Expression* Default Value: None $first_name == "Joe" startsWith($description, "Snap") && $quantity < 100 | String/Expression | The expression to evaluate. If this expression evaluates to true, then the document will be passed through. Otherwise, the document will be dropped. If the expression does not evaluate to a boolean, then the pipeline will fail. | |
Snap Execution Default Value: Validate & Execute | Dropdown list | Select one of the three modes in which the Snap executes. Available options are:
|
Examples
Filtering missing data or empty value using the Null-safe access option
This example Pipeline demonstrates how to filter data even when there is missing data or empty values using the Null-safe Access checkbox.
...
Configure the JSON Generator Snap with the following data. Each of the records have both location and salary except ID102
which does not have the location.
...
Now, if we configure the Filter expression as $location=="Hyderabad" || $salary>=20000 that means the Snap should filter and display the records in the output that has the location as Hyderabad OR the salary at least INR 20000.
...
If we select the Null-safe access checkbox, then even if the Snap finds any missing data while accessing the source path ( such as record#102 which does not have location), the Snap considers the field as null, which is a valid filter criteria.
After we validate the Pipeline, the Filter Snap returns the output as follows:
...
Downloads
Multiexcerpt include macro | ||||
---|---|---|---|---|
|
Attachments | ||
---|---|---|
|
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|