Nirmos
Knowledge

Index documents and content

Supply text, inspect indexing status, and reindex failed content.

Use an existing knowledge base and a key with knowledge:create to add documents, knowledge:read to inspect them, and knowledge:reindex for repairs. The base's embedding provider and vector storage must be available.

const document = await nirmos.knowledge.documents.create("knowledge-base-id", {
  title: "Refund policy", content: "Customers may request a refund within 30 days of purchase.",
  sourceType: "manual", mimeType: "text/plain", metadata: { category: "billing", revision: 1 },
});
if (document.status !== "ready" || document.vectorStatus !== "indexed") {
  throw new Error(`Document ${document.id} needs indexing repair: ${document.status}/${document.vectorStatus}`);
}
console.log(document.id);

Ingestion accepts supplied plain text/Markdown. A URL source records provenance; it does not download the URL. Each chunk receives its configured dense embedding, searchable text, and a native qdrant/bm25 sparse vector in the same Qdrant point. BM25 needs no separate provider credential, model selection, Python service, or GPU. A document becomes ready/indexed only after all batches complete. Creation can return a persisted failed document; inspect status before searching it.

Inspect and repair

const readiness = await nirmos.knowledge.searchStatus("knowledge-base-id");
console.log(
  readiness.exact.status,
  readiness.hybrid.status,
  readiness.progress,
);
const currentDocument = await nirmos.knowledge.documents.get(
  "knowledge-base-id",
  "document-id",
);
const chunks = await nirmos.knowledge.documents.chunks(
  "knowledge-base-id",
  "document-id",
  {
    limit: 25,
  },
);
console.log(currentDocument.vectorStatus, chunks.items.length);

Ordinary reindexing rebuilds chunks and their representations, calling the embedding provider. Reuse the persisted document ID after an indexing failure instead of creating a duplicate source.

await nirmos.knowledge.documents.reindex("knowledge-base-id", "document-id");

Document updates require knowledge:update; deletion requires knowledge:delete. Check indexing state after content changes. Removing documents affects future retrieval and is a mutation. Read search readiness for existing indexes that need lexical repair.

Document methods · RAG application

On this page