๐Ÿ‡ฌ๐Ÿ‡ง EN
๐Ÿ‡ฎ๐Ÿ‡น IT

๐Ÿ” RAG (Knowledge Base Search)

Performs a semantic vector search against one of your Knowledge Bases, returning the most relevant document excerpts. Use in combination with the Agent node to give AI models access to your private documents, product knowledge, or any other indexed content.

Category: Data Retrieval & Processing  ยท  Type identifier: rag

Overview

RAG stands for Retrieval-Augmented Generation. Instead of relying purely on the AI model's training data, RAG lets you retrieve the most relevant passages from your own documents and feed them to the model as context. This dramatically improves accuracy for questions about your specific domain, products, policies, or any information the model has not been trained on.

The RAG node takes a search query โ€” typically the user's question โ€” and performs a vector similarity search across all the documents you have indexed in the selected Knowledge Base. It returns the top-matching chunks, each scored by relevance. These results can then be injected directly into an Agent node via its Context Sources setting, or referenced manually in a prompt.

Before using this node, you must have at least one Knowledge Base with indexed documents. You can manage Knowledge Bases from the Knowledge Bases section of the main navigation.

Configuration

Field Status Description
Knowledge Base Required The Knowledge Base to search. Only Knowledge Bases with at least one document in completed status will return results.
Query Required The search query. Supports {{ variable }} references โ€” in most workflows, this is the user's question, such as {{ trigger.output.question }} or {{ form.output.query }}.
Limit Optional Maximum number of document chunks to return. Range is 1โ€“50. Default is 5. Returning more chunks gives the agent more context but increases prompt length and API cost.
Threshold Optional Minimum similarity score (0โ€“1) a chunk must achieve to be included in results. Default is 0.7. Higher values return only closely matching chunks; lower values cast a wider net. Set to 0 to return results regardless of similarity.
Query Expansion Optional When enabled, Flusso automatically generates several rephrased variations of the original query and searches with each. This improves recall for vague or ambiguous queries by finding relevant content that might not surface with the original wording alone.
Diversity Mode Optional When enabled, Flusso uses the MMR (Maximal Marginal Relevance) algorithm to select results that are both relevant to the query and diverse from each other. Use this when you want broad coverage across multiple aspects of a topic rather than several chunks from the same passage.
Diversity Lambda Optional Controls the balance between relevance and diversity when Diversity Mode is on. Range is 0โ€“1. A value of 1.0 returns purely the most relevant results (no diversity penalty). A value of 0.0 maximises diversity regardless of relevance. Default is 0.5.

Output Data

The RAG node produces an array of matching document chunks:

FieldTypeDescription
itemsarrayAn array of matching chunks, sorted by relevance score descending. Each item contains the fields below.
items[].textstringThe raw text content of the matching chunk.
items[].scorenumberThe similarity score (0โ€“1) indicating how closely this chunk matches the query.
items[].document_namestringThe name of the source document this chunk came from.
items[].metadataobjectAny additional metadata stored with this chunk (e.g. page number, section heading).
// Reference the full items array (e.g. to pass to a Reranker node) {{ rag_search.output.items }} // Access a specific chunk's text {{ rag_search.output.items[0].text }} // Check the score of the first result {{ rag_search.output.items[0].score }} // Source document name {{ rag_search.output.items[0].document_name }}

Example Usage

Answering questions from a product manual

  1. Add a RAG node. Select your product documentation Knowledge Base. Set Query to {{ trigger.output.question }}. Leave Limit at 5 and Threshold at 0.7.
  2. Add an Agent node after the RAG node. In the Agent's Context Sources setting, select the RAG step. Flusso will automatically format and inject the retrieved chunks into the agent's prompt.
  3. Set the Agent's User Prompt.
    {{ trigger.output.question }}
    The agent receives both the question and the relevant document excerpts, and generates a grounded answer.

Using results manually in a prompt

If you prefer to format the context yourself rather than using Context Sources:

// In the Agent's System Prompt or User Prompt: Use the following excerpts from our documentation to answer the question. Context: {{ rag_search.output.items[0].text }} {{ rag_search.output.items[1].text }} {{ rag_search.output.items[2].text }} Question: {{ trigger.output.question }}

Tips & Notes

Related Nodes