Skip to main content

Vector index

A vector index is a data structure that makes similarity search fast by avoiding a full scan. By default Ahnlich compares your query against every stored vector; a vector index pre-structures the vectors so only a fraction need to be checked.

Without an indexevery vector comparedWith an indexonly candidates checked
An index skips most of the store instead of scanning every vector.

Ahnlich offers two approaches, from exact-but-linear to approximate-but-fast:

  • Exact search — no index; always exact, but cost grows with the store.
  • HNSW — approximate, scales to high-dimensional embeddings.

Choosing an index

SituationUse
Small store, or you need exact resultsExact scan (no index)
Large store of high-dimensional embeddingsHNSW

An index costs extra memory and build time, and approximate indexes (HNSW) trade a little recall for speed — so add one when search latency actually matters.

Adding a vector index

Create one with Create non-linear index (or seed it at store creation); remove it with Drop non-linear index.

Filtering by metadata instead of vectors? That's a different structure — see predicate indexes.