Theme
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
| Property | Description | Default |
|---|---|---|
| Knowledge Base Collections | One or more collections to search. Select from your available KB collections. | Empty (required) |
| Query Template | The search query. Use {{last_message}} for the user's latest message, or write a custom query with variable interpolation. | {{last_message}} |
| Output Variable | The session variable to store the search results. | rag_results |
Advanced Settings
| Property | Description | Default |
|---|---|---|
| Top K Results | Number of top results to return. | 5 |
| Min Score | Minimum relevance score (0-1). Results below this threshold are excluded. | 0.7 |
| Include Source References | Whether to include source document metadata (file name, page number) in results. | false |
How It Works
- The query template is evaluated with current session variables.
- The query text is converted to a vector embedding.
- The embedding is compared against all document chunks in the selected collections using cosine similarity on pgvector.
- The top K results above the minimum score threshold are returned.
- 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
}
]RAG Query vs KB Search
| Feature | RAG Query | KB Search |
|---|---|---|
| Returns raw chunks | Yes | No (generates LLM answer) |
| Generates LLM response | No | Yes (built-in) |
| Multiple collections | Yes | Yes |
| Custom downstream prompting | Yes (via separate LLM node) | Limited (built-in prompt) |
| Output | Array of chunks with scores | Generated text answer |
RAG 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
Handles
| Handle | Direction | Description |
|---|---|---|
| Input | In | Receives execution from the previous node |
| Output | Out | Continues 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.
