Definition
HNSW index
An HNSW (Hierarchical Navigable Small World) index is a data structure for approximate nearest-neighbor search over vector embeddings. It organizes vectors into a layered graph that can be traversed greedily, so a query finds its closest matches in roughly logarithmic time instead of comparing against every vector — the workhorse that makes semantic search and RAG fast at scale.
Key takeaways
- An HNSW index is a layered graph structure for fast approximate nearest-neighbor search over vector embeddings.
- It finds closest matches in roughly logarithmic time instead of comparing against every vector.
- Being approximate is the point — a tunable recall/speed tradeoff gives near-exact results in milliseconds.
- Planoda stores embeddings with HNSW indexes in PostgreSQL so semantic search and RAG stay fast and tenant-scoped.
Semantic search reduces to a geometry problem: given a query vector, find the nearest stored vectors. Doing that exactly means measuring distance to every item, which is hopeless across millions of embeddings. HNSW trades a sliver of exactness for enormous speed by building a navigable graph in layers — sparse long-range links at the top for fast approach, dense local links at the bottom for precision — so a search hops toward the right neighborhood and then refines, touching a tiny fraction of the data.
Being approximate is the point, not a flaw. The recall/speed tradeoff is tunable through build and query parameters, and for retrieval — where 'good enough, instantly' beats 'perfect, eventually' — near-exact results in milliseconds are exactly what's wanted. HNSW has become the default index behind production vector search for this reason.
Planoda stores issue and document embeddings with HNSW indexes inside PostgreSQL, so meaning-based search and the retrieval step of its AI features stay interactive and tenant-scoped even as a workspace's data grows.
Related terms
- Vector DatabaseA vector database stores data as high-dimensional embeddings and retrieves items by similarity rather than exact match. Given a query vector, it returns the nearest stored vectors — the records most similar in meaning. Specialized indexes make this fast across millions of items, making vector databases the retrieval backbone of semantic search and AI applications.
- Semantic SearchSemantic search finds results by meaning rather than exact keywords, using vector embeddings that place similar concepts near each other in mathematical space. A query for 'login broken' can surface an issue titled 'users can't authenticate' even with no shared words. It powers more relevant search and is the retrieval layer behind many AI features.
- EmbeddingAn embedding is a numeric vector that represents a piece of content — text, image, or other data — as a point in high-dimensional space, positioned so that similar items land near each other. Produced by a model trained to capture meaning, embeddings let software compare content by semantic similarity rather than by matching exact words.
- Retrieval-Augmented Generation (RAG)Retrieval-augmented generation (RAG) grounds a language model's answers in your own data by retrieving the most relevant documents at query time and feeding them into the model's context before it responds. Instead of relying solely on what the model memorized in training, RAG lets it answer from current, authoritative, private sources — sharply reducing hallucination.
- RerankingReranking is a second-stage refinement in retrieval that reorders an initial set of candidate results by relevance to the query, using a more precise but costlier model. A fast first pass casts a wide net; the reranker then scores each candidate against the query directly, promoting the truly best matches to the top — sharply improving the quality of retrieval.