ReadonlydimVector dimensionality.
ReadonlysizeNumber of points currently in the index.
v3.9.0-rc.2 — apply a live-update diff to the in-memory index. The
watcher calls this after embedDb.upsertNoteWithCanonicalVectors() returns its
{ oldIds, newIds, newVectors }, and passes the DB-canonical
newVectors, so search reflects the exact persisted numeric generation
immediately
(pre-3.9.0, search was stale until the next serve restart rebuilt
the index from the freshly upserted embed-db).
Semantics:
removeLabels is markDelete'd. Missing labels
(e.g. a stale watcher tracking a label that was already evicted)
are silently skipped.addPoints is addPoint'd with replaceDeleted
= true so deleted-but-allocated slots are reused before the
index grows. Throws (wrapped) if capacity is exhausted AND the
caller didn't pre-grow via resize.Atomicity: the SDK's underlying mutations are synchronous, but
applyDiff does not wrap them in a transaction. A throw mid-loop
leaves the index in a partial-update state (some labels removed,
some new points added, others not). Callers MUST treat throws as
"rebuild required" — there's no rollback path in hnswlib. The method also
throws before its first native mutation if a persistence snapshot is in
flight, so writeIndex can never race C++ graph mutation.
the number of labels removed + the number of points added
(for logging / instrumentation). Sum should equal
removeLabels.length + addPoints.length on success.
v3.9.0-rc.2 — grow the index to at least newMaxElements. No-op if
already large enough. Used by the watcher before applyDiff when
the live-update would push us past current capacity. Native call
is synchronous (in-place re-allocation). Throws before resizing if a
persistence snapshot is in flight.
v2.16.0 — persist the index to disk for fast reload on next serve
start. Writes an immutable <file>.<nonce>.bin generation, then
atomically publishes <file>.meta.json last as its basename + SHA-256
pointer. Returns true once that pointer commits; prior-generation cleanup
is best-effort and cannot turn a committed save into a reported failure.
file must use the exact lowercase .hnsw suffix so separate configured
bases cannot collide with one another's generated artifacts. A missing
parent is requested via recursive
mode-0700 mkdir subject to a more-restrictive umask; an existing/custom
parent is never path-chmod'd. Saves
on one wrapped index serialize in invocation order. A queued save whose
graph epoch changed before it starts rejects without publishing; live
native mutation is mutually excluded while writeIndex is in flight.
Compact pointer metadata larger than 64 KiB or a native generation larger
than 1 GiB is refused before pointer publication; the already-built
in-memory graph remains usable. Precommit orphan cleanup is best-effort: a failed cleanup
may leave a strict generated residue that explicit clear/prune covers.
Exact lowercase .hnsw persistence base.
Exact DB-owned live-label metadata manifest. It is validated against the graph but is not copied into the compact pointer.
Embed-database generation signature bound into the pointer.
OptionaldbGeneration: Readonly<HnswDbGenerationAuthority>
Exact DB UUID/epoch. Optional only for legacy source compatibility; current receipt signatures carry the same fields.
OptionalpersistenceScopes: PersistenceFamilyScopes
Pinned primary EmbedDb family scopes. Custom HNSW basenames require this authority; only default hash basenames may use the legacy fresh-resolution fallback.
Optionalpublication: HnswPublicationReceiptSink
Optional caller-owned receipt slot. It is cleared at invocation and populated before the meta-last commit attempt, so it also remains available when a later publisher-lease release throws.
true after the meta-last pointer commits.
k-NN search. Returns labels + distances (cosine distance, smaller =
more similar). Caller maps labels back to source rows via the same
LabeledVector.label they used at build time.
Optionalopts: HnswQueryOptions
In-memory HNSW index over L2-normalized cosine vectors. Built once on serve start from
EmbedDb.getAllVectors(); queried perobsidian_search/obsidian_embeddings_searchinvocation.