Skip to content

Filter Data

The Filter Data component lets you pick out only the pieces of information you need from a Data or Document object.
You can keep just the fields you want, or throw away the ones you don’t. It works entirely inside Nappai, so no external services are called.

How it Works

When you drop a Data or Document into the component, it looks at each item one by one.

  • Filter Criteria – a list of keys (you can use dot notation like headers.Accept for nested fields).
  • Exclude Keys – a simple toggle.
    • If off (the default), the component keeps only the keys you listed.
    • If on, it removes the listed keys and keeps everything else.

The component walks through the data structure, finds the requested keys (case‑insensitive), and builds a new object that contains only the selected information.
If you fed a single item, you’ll get a single filtered object back; if you fed a list, you’ll get a list of filtered objects.

Inputs

  • Input Data: A single Data/Document or a list of them.
    The component will process each item in the list and return a filtered version of the same type.

  • Exclude Keys: If enabled, the keys you list in Filter Criteria will be removed from the data.
    If disabled, only the listed keys will be kept.

  • Filter Criteria: A list of keys to filter.
    Use dot notation for nested keys (e.g., headers.Accept).
    The component is case‑insensitive when matching keys.

Outputs

  • Filtered Data: The result of the filtering operation.
    It is returned as a Data object (or a Document if the input was a Document).
    The output can be used directly in subsequent components or stored for later use.

Usage Example

Suppose you have a Document that contains an email with many headers, but you only need the Subject and From fields.

  1. Drag the Filter Data component onto the canvas.
  2. Connect the Document output from the previous component to Input Data.
  3. In Filter Criteria, add:
    headers.Subject
    headers.From
  4. Leave Exclude Keys turned off (the default).
  5. Run the workflow.
  6. The Filtered Data output will contain only the Subject and From headers, plus any other required fields for a Document (like page_content).

You can also reverse the logic: set Exclude Keys to true and list all the headers you want to drop, keeping everything else.

  • Merge Data – Combine multiple Data objects into one.
  • Transform Data – Apply custom transformations or calculations.
  • Extract Data – Pull specific values out of a Data object for use elsewhere.

Tips and Best Practices

  • Use dot notation (parent.child) to target nested fields; the component will find them even if the case differs.
  • When filtering a large list, keep the Filter Criteria short to avoid unnecessary processing.
  • If you only need a few fields, leave Exclude Keys off; it’s faster to keep what you need than to delete what you don’t.
  • For Documents, remember that the component will always add page_content and metadata if they’re missing, so the output remains a valid Document.

Security Considerations

  • The component runs locally within Nappai; no data leaves your environment.
  • Be mindful of sensitive fields (e.g., passwords, tokens). If you’re excluding them, double‑check that they’re not inadvertently re‑included elsewhere in the workflow.
  • Because the component is case‑insensitive, avoid naming keys that could clash with system‑reserved fields.