Class FilterExecutor

java.lang.Object
ai.nervemind.app.executor.FilterExecutor
All Implemented Interfaces:
NodeExecutor

@Component public class FilterExecutor extends Object implements NodeExecutor
Executor for the "filter" node type - filters arrays based on conditions.

Processes an array of items and returns only those that match specified conditions. Uses the same condition evaluation logic as SwitchExecutor for consistency across conditional operations.

Node Parameters

Filter node configuration parameters
ParameterTypeDefaultDescription
inputFieldString"items"Field containing array to filter
outputFieldString"filtered"Field to store filtered results
conditionsList[]List of condition objects
combineWithString"and""and" or "or" - how to combine conditions
keepMatchingBooleantruetrue to keep matching items, false to keep non-matching

Condition Structure

Same as SwitchExecutor - each condition has field, operator, and value.

Example Configuration

{
"inputField": "products",
"outputField": "activeProducts",
"conditions": [
{ "field": "status", "operator": "equals", "value": "active" },
{ "field": "price", "operator": "greaterThan", "value": 0 }
],
"combineWith": "and"
}

Output Data

Output keys added by this executor
KeyTypeDescription
[outputField]ListArray of items that matched conditions
_filteredCountIntegerNumber of items in result
_originalCountIntegerNumber of items before filtering
_removedCountIntegerNumber of items removed by filtering
See Also:
  • Constructor Details

    • FilterExecutor

      public FilterExecutor()
      Default constructor.
  • Method Details

    • execute

      public Map<String,Object> execute(ai.nervemind.common.domain.Node node, Map<String,Object> input, ExecutionService.ExecutionContext context)
      Description copied from interface: NodeExecutor
      Executes the business logic for this node type.
      Specified by:
      execute in interface NodeExecutor
      Parameters:
      node - The node definition containing parameters and configuration. Use Node.parameters() to access user settings.
      input - Combined output from all upstream nodes that connected to this node. For simple flows, this contains the direct predecessor's output. For merge nodes, it contains combined data.
      context - Verification context providing access to workflow-scoped services, logger, and execution metadata.
      Returns:
      A Map containing the results of this node's execution. Keys in this map become available variables for downstream nodes.
      Note: Returning null is treated as an empty map.
    • getNodeType

      public String getNodeType()
      Description copied from interface: NodeExecutor
      Unique identifier for the node type this executor handles. This must match the 'type' field in the JSON definition of the node.
      Specified by:
      getNodeType in interface NodeExecutor
      Returns:
      The unique type string (e.g., "httpRequest", "llmChat").