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.
- HNSW
An approximate nearest-neighbour method based on a graph, which powers ANN queries in AI Search and measures closeness with L2 distance.
- Hybrid search
Set
query_type="hybrid"in AI Search to run keyword and vector matching together, with Reciprocal Rank Fusion producing the final order. Expect a 200-result ceiling and roughly four times the resource use of ANN. - 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.
- RRF
Reciprocal Rank Fusion: how a hybrid query in AI Search turns separate full-text and ANN lists into a single order, using an
rrf_paramof 60. - similarity_search
Lets application code search an AI Search index through the Python SDK. Set
query_typefor a mode such as hybrid; otherwise it runs ANN.