Short for approximate nearest neighbour: a vector search that finds most of the closest matches rather than guaranteeing every one, trading completeness for speed and lower cost. DiskANN and HNSW indexes work this way, whereas flat search is exact.
Also called approximate nearest neighbour.
Read more: Microsoft Learn
In the Ultra Transcenders books
Each book explains ANN in context, with comparison tables and the common traps.
Terms in this definition
- Vector search
Searching embeddings for similar meaning, so paraphrases are found via nearest-neighbour algorithms like HNSW; exact identifiers, however, may be missed.
- DiskANN
A vector index from Microsoft Research for approximate nearest-neighbour search. Azure Cosmos DB offers it as diskANN (vectors of up to 4,096 dimensions) and Azure Database for PostgreSQL as pg_diskann, and it works best once a collection holds more than roughly 50,000 vectors.
- HNSW
Graph-structured index for approximate vector search in RediSearch and pgvector. Compared with IVFFlat, recall versus speed is better, though building takes longer and memory use is higher.
- FLAT
A RediSearch vector index that compares every vector exactly, by brute force. It fits smaller data sets or cases needing complete results, whereas HNSW is approximate.
Related terms
- Exact nearest neighbour
Measures how far the query vector is from each and every candidate, for instance using VECTOR_DISTANCE with TOP and ORDER BY, so the results are always right. It is advised for up to roughly 50,000 candidates; beyond that, ANN (approximate) search is preferred.
- Recall
A measure of approximate (ANN) vector search accuracy: what fraction of the true nearest neighbours, as found by an exact kNN search, the approximate search returned. A value of 1 means nothing was approximated.