Search and retrieval
Choose semantic, exact phrase, or hybrid search and interpret evidence.
Use an indexed base and knowledge:search. Retrieval returns matching content and source information; it does not execute Gateway or insert context into prompts.
Search modes
| Mode | How it works | Recommended use | Limits |
|---|---|---|---|
| Semantic | Embeds the query with the KB's fixed model and searches dense vectors. | Questions, paraphrases, concept discovery. | Calls the embedding provider; related text need not contain the query words. |
| Exact Text | Qdrant's indexed phrase filter finds consecutive word tokens. | Known wording, quotations, policy phrases. | Case-insensitive and tokenized; punctuation is ignored as a separator. No semantic expansion or byte-for-byte substring guarantee. |
| Hybrid | Dense retrieval and native BM25 lexical retrieval run together; Qdrant fuses ranks with RRF. | Questions containing distinctive terms, names, or technical vocabulary. | Calls the dense embedding provider once; needs completed sparse indexing. Fusion score is not a similarity percentage. |
Exact Text preserves accents and word order, retains single-character words, and uses no stemming or stopword removal. quick brown matches QUICK, brown, but not brown quick or quick red brown. Matching stays within an individual chunk. Queries need at least one word or number. Identifier punctuation is not literal: put identifiers in scalar metadata and use an equality filter when punctuation/case must be preserved.
BM25 uses lowercase word tokens with no stemming or stopword removal, suitable for mixed-language and technical content. It ranks lexical overlap using term frequency, length normalization, and IDF. Collections remain shared by embedding configuration, so IDF statistics are collection-wide. RRF combines branch ranks, rather than adding incompatible dense and lexical scores.
const semantic = await nirmos.knowledge.search("knowledge-base-id", {
query: "How long do customers have to request a refund?",
mode: "semantic", // also the default when omitted
topK: 5,
minScore: 0.3,
filters: { category: "billing" },
});
const exact = await nirmos.knowledge.search("knowledge-base-id", {
query: "within 30 days",
mode: "exact",
topK: 5,
documentIds: ["document-id"],
});
const hybrid = await nirmos.knowledge.search("knowledge-base-id", {
query: "refund request 30 days",
mode: "hybrid",
topK: 5,
});
for (const match of hybrid.items) {
console.log(match.content, match.score, match.source.title);
}
console.log(exact.mode, exact.scoreType); // "exact", nullSearch returns { mode, scoreType, items, nextCursor } after SDK decoding. Items include chunkId, documentId, content, score, nullable scalar metadata and source title/URI/type. Results use current authoritative document content and versions. Search retrieves evidence; it does not generate an answer. Retrieval configuration explains score meanings and filtering.
Retrieval configuration owns filters, pagination and readiness. Build a RAG application to turn evidence into a grounded request.