All nodes/AI/RAG

RAG Query

Performs a semantic search over the knowledge base and returns relevant context. Takes the query via the 'query' port and the KB via the 'kb' port. The result is passed to the LLM to generate an answer.

RAG Query
QueryContext
KB
Embedding

Type in the graph: rag_query

Exec

An error branch can be enabled (expose_error_output) to handle failures on their own path.

Ports can be split into separate execution and data handles.

Try it

Minimal working workflow

Entry
RAG Query
Exit
  • Execute + Data
Press “Copy nodes”, open the editor and hit Ctrl+V on the canvas.

Pick your own connection or knowledge base first — the graph carries REPLACE_ME.

When to use it

Reach for RAG Query when the context from a base is needed every time: a reference answer, a documentation lookup, fragments injected into a prompt before generation. The search runs on every pass, its result is predictable and visible in the run log. If the model itself should decide whether to search, that is RAG Tool. If you need to re-rank what was already found, put Rerank after it.

How it works

The Query port carries both the trigger and the query text. When only execution arrives there, the text comes from the Query field — a template such as {{ inputs.query }} or {{ nodes.x.output.text }}. The query is then turned into a vector and compared against the chunks of the base.

The output is an object: context (the joined chunks), chunks (an array with score, document_id, chunk_id and metadata), query and kb_found. With the text format the chunks are joined by a --- separator; with json the context holds the serialised array. The context window adds neighbouring chunks of the same document around every hit, and a score threshold of 0 means “keep everything”.

The Embedding port accepts a ready vector from Embed Text — the query is then not embedded a second time. That vector must come from the same model as the base, otherwise the dimensions do not match.

Common mistakes

  • Reading an empty result as a breakage. kb_found: true with an empty context means the base is there and nothing matched; false means the base was not found (deleted, or owned by another workspace).
  • Sending the whole object into a prompt. Use {{ nodes.<id>.output.context }} in the template, otherwise the model receives JSON with scores and metadata instead of text.
  • Nothing connected to the Query port. The node will not run: it has no separate execution input, the trigger arrives through that very port.
  • Editing Top K here while a Knowledge Base node is connected. Top K, the threshold and the context window then arrive from there and the fields here are inactive.
  • Raising the threshold “just in case”. Similarity values depend on the embedding model; start at 0 and raise it while looking at the real score values in the log.

Inputs

PortWirePayloadNotes
QueryqueryExecute + Dataexecute_data

Search text; replaces the Query template when connected

KBkbDatadata

Knowledge Base node config: kb_id/top_k/score_threshold/context_window override the fields here, metadata_filters are combined with them

EmbeddingembeddingDatadata

Precomputed query vector from an embed_text node; skips embedding the query text again

Outputs

PortWirePayloadNotes
ContextoutputExecute + Dataexecute_dataobject

Configuration

FieldTypeDefaultDescription
Queryquery_templatestring{{inputs.query}}

Query text. Supports {{inputs.query}}, {{nodes.x.output.text}}

supports templates

Knowledge Basekb_idstring""

Knowledge base to search. A connected Knowledge Base node supplies this value and wins over the field.

overridden by port: kb

Top Ktop_kinteger5

Maximum number of chunks to return. A connected Knowledge Base node supplies this value and wins over the field.

overridden by port: kb

Output Formatformatstringtext

text: concatenated chunks separated by ---. json: array with metadata.

Options: text — Text, json — JSON

Advanced
Score Thresholdscore_thresholdnumber0

Minimum similarity score a chunk must reach. A connected Knowledge Base node supplies this value and wins over the field.

overridden by port: kb

Context Windowcontext_windowinteger0

Neighboring chunks to include around each result (0 = disabled). A connected Knowledge Base node supplies this value and wins over the field.

overridden by port: kb

Metadata Filtersmetadata_filtersarray

Hard filters over chunk metadata (AND). Operators: = != < > <= >=. Combined with the connected KB node's filters rather than replaced by them.

Shared fields

Every node has these three — the platform adds them, not the node author.

  • expose_error_output — When enabled, show an execution output to connect nodes that run if this step fails.
  • split_ports_in — Show separate execution and data input handles instead of one combined port.
  • split_ports_out — Show separate execution and data output handles instead of one combined port.

Ready-made examples using this node