Output Ports
| Port | Description |
| success | Operation completed. For query: results array populated. For insert/update: item stored. For delete: item removed. |
| error | Backend connection failure, embedding model error, invalid collection name, or item not found (for update/delete). |
insert / update Output
| Field | Type | Description |
item_id | string | The ID of the inserted or updated knowledge item. |
collection_name | string | The collection the item was stored in. |
embedding_dimensions | integer | Dimensionality of the embedding vector generated (e.g. 1536 for OpenAI text-embedding-3-small). |
operation | string | inserted or updated. |
query Output
| Field | Type | Description |
results | array | Array of the top-K matching knowledge items, ordered by similarity score descending. Each result object contains item_id, text, score, and metadata. |
query_text | string | The original query string as submitted. |
result_count | integer | Number of results returned (may be less than top_k if fewer items exceed the min_score threshold). |
sources | array | Array of item_id strings for all returned results — convenient for citation in AI-generated responses. |
context_text | string | All result texts concatenated into a single string, formatted for direct injection into an AI prompt as context. Separated by dividers. |
Result Item Schema
| Field | Type | Description |
item_id | string | Unique ID of this knowledge item. |
text | string | The original knowledge item text that was stored. |
score | float | Cosine similarity score between the query and this item (0.0–1.0). Higher is more similar. |
metadata | object | All metadata tags stored with this item. |
Example: query Output
{
"query_text": "What is the company's policy on remote work?",
"result_count": 3,
"sources": ["policy-remote-work-v4", "policy-flexible-hours-v2", "faq-wfh-001"],
"context_text": "---\nEmployees are eligible for remote work up to 3 days per week after completing 90 days of employment...\n---\nFlexible working hours are available between 7am and 7pm...\n---\nWork-from-home equipment allowance is $500 per calendar year...\n---",
"results": [
{
"item_id": "policy-remote-work-v4",
"text": "Employees are eligible for remote work up to 3 days per week after completing 90 days of employment. A minimum of 2 days per week must be spent in the office. Remote work requires manager approval and a compliant home office setup.",
"score": 0.924,
"metadata": { "category": "hr", "policy_type": "remote-work", "version": "4", "effective_date": "2025-01-01" }
},
{
"item_id": "policy-flexible-hours-v2",
"text": "Flexible working hours are available between 7am and 7pm local time. Core hours of 10am–3pm must be observed for team collaboration.",
"score": 0.812,
"metadata": { "category": "hr", "policy_type": "working-hours", "version": "2" }
},
{
"item_id": "faq-wfh-001",
"text": "Work-from-home equipment allowance is $500 per calendar year for approved peripheral devices and ergonomic equipment.",
"score": 0.774,
"metadata": { "category": "hr", "type": "faq", "topic": "wfh-expenses" }
}
]
}
Using context_text in AI prompts: The context_text field is pre-formatted for direct injection into AI node prompts. Use it as: Based on the following company policies, answer the employee's question.\n\nPolicies:\n{{ nodes.ragQuery.output.context_text }}\n\nQuestion: {{ vars.user_question }}
Handling Zero Results
When no results meet the min_score threshold, the node routes to the success port with result_count: 0 and an empty results array. Always check result_count before attempting to access results[0] — accessing an index on an empty array will cause a downstream expression error.
// Recommended pattern in downstream IfCondition node:
{@ $node.ragNode.result_count } > 0
// True path: use retrieved context in AI prompt
// False path: use a generic fallback response or escalate to human
Expression Reference for Downstream Nodes
| Expression | Returns |
{@ $node.ragNode.results } | Full results array |
{@ $node.ragNode.results[0].text } | Text of the most relevant result |
{@ $node.ragNode.results[0].score } | Similarity score of the top result (0.0–1.0) |
{@ $node.ragNode.results[0].item_id } | ID of the top result (for citation) |
{@ $node.ragNode.results[0].metadata.category } | Category metadata of the top result |
{@ $node.ragNode.result_count } | Number of results returned |
{@ $node.ragNode.query_text } | The query that was searched |
{@ $node.ragNode.context_text } | All result texts concatenated for AI prompt injection |
{@ $node.ragNode.sources } | Array of result item IDs for citation |
{@ $node.ragNode.item_id } | ID of item inserted/updated/deleted |
{@ $node.ragNode.operation } | Operation performed: inserted/updated/deleted |
Example Output — insert
{
"item_id": "policy-remote-work-v4",
"operation": "inserted",
"collection_name": "hr-policies",
"embedding_dimensions": 1536,
"timestamp": "2026-05-23T09:14:22.481Z"
}
Example Output — query (zero results)
{
"query_text": "What is the policy for company vehicles?",
"result_count": 0,
"results": [],
"sources": [],
"context_text": "",
"collection_name": "hr-policies"
}
When result_count is 0, either no items exist in the collection matching the query above the min_score threshold, or no items matching the metadata_filter were found at all. Handle this in a downstream IfCondition to route to a fallback response.
Example: Building a RAG Prompt in a DataMapping Node
// Use a DataMapping node between FlowRag query and AI node
// to construct a well-formatted prompt:
{
"prompt": "You are an HR assistant for BizFirstGO. Answer the employee's question using the company policies below. If the answer is not covered by the policies, say so clearly.\n\nCompany Policies:\n{@ $node.ragQuery.context_text }\n\nEmployee Question: {@ $var.employeeQuestion }\n\nAnswer in a friendly, professional tone in 2-4 sentences.",
"cited_policies": "{@ $node.ragQuery.sources }"
}
Score interpretation: A high score does not always mean the retrieved document answers the question — it means the document is semantically similar to the query. A score of 0.85 between "What is the annual leave policy?" and a document about sick leave is plausible. Always instruct the AI downstream to say "I don't know" or "This policy doesn't directly address your question" if the retrieved context doesn't contain the answer, rather than hallucinating one.
insert and update — Additional Output Fields
| Field | Type | Description |
item_id | string | The ID of the knowledge item as stored or updated. Use this to confirm the correct item was written. |
collection_name | string | The collection that was modified. |
embedding_dimensions | integer | Dimensionality of the embedding vector generated — confirms which embedding model was active. |
operation | string | inserted or updated — confirms which action was taken. |
timestamp | string | ISO 8601 timestamp of the write operation for audit logging. |