Skip to content

RAG Query Node

The RAG Query node performs a vector similarity search against one or more Knowledge Base collections and returns the most relevant document chunks. Unlike the KB Search node, the RAG Query node returns raw search results without generating an LLM response -- giving you full control over how the results are used downstream.

When to Use

  • You want to retrieve relevant document chunks and pass them as context to a separate LLM Response node.
  • You need fine-grained control over the RAG pipeline (search parameters, result filtering, custom prompting).
  • You want to combine results from multiple Knowledge Base collections in a single query.
  • You need access to the raw relevance scores and source metadata.

Configuration

PropertyDescriptionDefault
Knowledge Base CollectionsOne or more collections to search. Select from your available KB collections.Empty (required)
Query TemplateThe search query. Use {{last_message}} for the user's latest message, or write a custom query with variable interpolation.{{last_message}}
Output VariableThe session variable to store the search results.rag_results

Advanced Settings

PropertyDescriptionDefault
Top K ResultsNumber of top results to return.5
Min ScoreMinimum relevance score (0-1). Results below this threshold are excluded.0.7
Include Source ReferencesWhether to include source document metadata (file name, page number) in results.false

How It Works

  1. The query template is evaluated with current session variables.
  2. The query text is converted to a vector embedding.
  3. The embedding is compared against all document chunks in the selected collections using cosine similarity on pgvector.
  4. The top K results above the minimum score threshold are returned.
  5. Results are stored in the output variable as an array of objects, each containing the chunk text, relevance score, and source metadata.

Output Format

The output variable contains an array of result objects:

json
[
  {
    "content": "The return policy allows returns within 30 days...",
    "score": 0.94,
    "source": "return-policy.pdf",
    "page": 3
  },
  {
    "content": "Refunds are processed within 5-7 business days...",
    "score": 0.87,
    "source": "faq.md",
    "page": null
  }
]
FeatureRAG QueryKB Search
Returns raw chunksYesNo (generates LLM answer)
Generates LLM responseNoYes (built-in)
Multiple collectionsYesYes
Custom downstream promptingYes (via separate LLM node)Limited (built-in prompt)
OutputArray of chunks with scoresGenerated text answer
imageRAG Query node config panel showing Knowledge Base collection multi-select, query template field with variable interpolation, output variable name, Top K results slider, Min Score threshold, and Include Source References toggle
RAG Query configuration panel

Handles

HandleDirectionDescription
InputInReceives execution from the previous node
OutputOutContinues to the next node after results are retrieved

TIP

For most use cases, the KB Search node is simpler since it handles both retrieval and LLM generation in one step. Use RAG Query when you need more control over the pipeline.

OmniBots AI Bot Platform