curl -X POST "https://your-domain.com/api/v1/retrieval/query/collection" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"collection_names": ["kb_123abc"],
"query": "How do I install the software?",
"k": 5,
"hybrid": true
}'
{
"distances": [[0.234, 0.289, 0.312, 0.445, 0.521]],
"documents": [[
"To install the software, follow these steps: 1. Download the installer from our website...",
"Installation requirements: Operating System: Windows 10 or later, macOS 11+...",
"For Linux installation, use the following command: sudo apt-get install...",
"After installation, launch the application from the Start menu or Applications folder...",
"The setup wizard will guide you through the initial configuration..."
]],
"metadatas": [[
{
"file_id": "file_abc123",
"name": "installation_guide.pdf",
"source": "installation_guide.pdf",
"created_by": "user_456def",
"embedding_config": {
"engine": "openai",
"model": "text-embedding-3-small"
}
},
{
"file_id": "file_abc123",
"name": "installation_guide.pdf",
"source": "installation_guide.pdf",
"created_by": "user_456def",
"embedding_config": {
"engine": "openai",
"model": "text-embedding-3-small"
}
}
]],
"ids": [[
"chunk_uuid_1",
"chunk_uuid_2",
"chunk_uuid_3",
"chunk_uuid_4",
"chunk_uuid_5"
]]
}
Knowledge
Query Knowledge Bases
Perform semantic search across knowledge base collections
POST
/
api
/
v1
/
retrieval
/
query
/
collection
curl -X POST "https://your-domain.com/api/v1/retrieval/query/collection" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"collection_names": ["kb_123abc"],
"query": "How do I install the software?",
"k": 5,
"hybrid": true
}'
{
"distances": [[0.234, 0.289, 0.312, 0.445, 0.521]],
"documents": [[
"To install the software, follow these steps: 1. Download the installer from our website...",
"Installation requirements: Operating System: Windows 10 or later, macOS 11+...",
"For Linux installation, use the following command: sudo apt-get install...",
"After installation, launch the application from the Start menu or Applications folder...",
"The setup wizard will guide you through the initial configuration..."
]],
"metadatas": [[
{
"file_id": "file_abc123",
"name": "installation_guide.pdf",
"source": "installation_guide.pdf",
"created_by": "user_456def",
"embedding_config": {
"engine": "openai",
"model": "text-embedding-3-small"
}
},
{
"file_id": "file_abc123",
"name": "installation_guide.pdf",
"source": "installation_guide.pdf",
"created_by": "user_456def",
"embedding_config": {
"engine": "openai",
"model": "text-embedding-3-small"
}
}
]],
"ids": [[
"chunk_uuid_1",
"chunk_uuid_2",
"chunk_uuid_3",
"chunk_uuid_4",
"chunk_uuid_5"
]]
}
Query one or more knowledge base collections using semantic search. Returns the most relevant document chunks based on vector similarity and optional reranking.
Request
Request Body
Array of knowledge base collection IDs to query. Each knowledge base has a unique collection ID.
The search query text. Will be embedded and compared against document embeddings.
Number of results to return (default: configured TOP_K value). For hybrid search, this is the initial retrieval size before reranking.
Number of results after reranking (only applies when hybrid search is enabled). Default: configured TOP_K_RERANKER.
Relevance threshold (0.0 to 1.0). Results below this threshold are filtered out. Default: configured RELEVANCE_THRESHOLD.
Whether to use hybrid search (vector + BM25 + reranking). Default: based on ENABLE_RAG_HYBRID_SEARCH setting.
Weight for BM25 scores in hybrid search (0.0 to 1.0). Default: configured HYBRID_BM25_WEIGHT.
Whether to include enriched text snippets. Default: ENABLE_RAG_HYBRID_SEARCH_ENRICHED_TEXTS.
Headers
Bearer token for authentication
Response
Returns an array of relevant document chunks ranked by relevance score.Array of arrays containing distance scores (lower is more similar). One array per collection queried.
Array of arrays containing the text content of matching chunksExample:
[["Product guide chapter 1...", "Setup instructions..."]]Array of arrays containing unique chunk IDs
(Hybrid search only) Relevance scores after reranking (higher is better)
curl -X POST "https://your-domain.com/api/v1/retrieval/query/collection" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"collection_names": ["kb_123abc"],
"query": "How do I install the software?",
"k": 5,
"hybrid": true
}'
{
"distances": [[0.234, 0.289, 0.312, 0.445, 0.521]],
"documents": [[
"To install the software, follow these steps: 1. Download the installer from our website...",
"Installation requirements: Operating System: Windows 10 or later, macOS 11+...",
"For Linux installation, use the following command: sudo apt-get install...",
"After installation, launch the application from the Start menu or Applications folder...",
"The setup wizard will guide you through the initial configuration..."
]],
"metadatas": [[
{
"file_id": "file_abc123",
"name": "installation_guide.pdf",
"source": "installation_guide.pdf",
"created_by": "user_456def",
"embedding_config": {
"engine": "openai",
"model": "text-embedding-3-small"
}
},
{
"file_id": "file_abc123",
"name": "installation_guide.pdf",
"source": "installation_guide.pdf",
"created_by": "user_456def",
"embedding_config": {
"engine": "openai",
"model": "text-embedding-3-small"
}
}
]],
"ids": [[
"chunk_uuid_1",
"chunk_uuid_2",
"chunk_uuid_3",
"chunk_uuid_4",
"chunk_uuid_5"
]]
}
Query Single Document Collection
For querying a single file’s collection:POST /api/v1/retrieval/query/doc
Request Body
Single collection name (usually
file-{file_id} for individual files)Search query text
Number of results to return
Number of results after reranking
Relevance threshold
Enable hybrid search
Search Modes
Vector Search (Default)
- Embeds your query using the configured embedding model
- Performs cosine similarity search against document embeddings
- Fast and efficient for semantic similarity
Hybrid Search
Whenhybrid=true or ENABLE_RAG_HYBRID_SEARCH is enabled:
- Vector Search: Retrieves top
kresults by embedding similarity - BM25 Search: Retrieves results using keyword matching
- Fusion: Combines results using
hybrid_bm25_weight - Reranking: Uses cross-encoder model to rerank to top
k_rerankerresults - Filtering: Removes results below relevance threshold
r
Access Control
- Users can only query knowledge bases they have read access to
- Collection names are validated against user permissions
- Access is granted based on:
- Knowledge base ownership
- Group membership with read permissions
- Admin role
Notes
- Query embedding uses the same model as document embedding for consistency
- Results are returned in order of relevance (most relevant first)
- The
distancesfield contains cosine distances (lower = more similar) - The
scoresfield (hybrid search only) contains reranking scores (higher = better) - Multiple collections are queried in parallel for efficiency
- Results can be filtered by relevance threshold to improve quality
⌘I