# How do HNSW and exhaustive nearest-neighbor search differ in Azure AI Search?

Exam: AI-300 — Operationalizing Machine Learning and Generative AI Solutions
Knowledge domain: Optimize generative AI systems and model performance
Updated: 2026-11-25T04:35:46.380473+00:00
HTML: https://learningpathx.com/faq/AI-300/ai300-hnsw-exhaustive-vector-retrieval.html

## Also asked as

- When should I compare HNSW retrieval with exhaustive KNN in Azure AI Search?
- What are the recall and resource tradeoffs between approximate HNSW and exhaustive vector search?

HNSW performs approximate nearest-neighbor retrieval, while exhaustive KNN scans the vector space to find the nearest neighbors under the configured metric. The choice trades retrieval efficiency, resource use and nearest-neighbor recall; it does not by itself establish task relevance.

HNSW uses a graph to narrow the search and supports efficient retrieval at scale. Exhaustive search is more computationally intensive and can provide an exact nearest-neighbor reference for evaluating approximate recall. Azure AI Search supports exhaustive querying on HNSW-indexed fields, but an exhaustive-only index lacks the graph needed for HNSW querying.

Even exact nearest neighbors can be irrelevant to the user's evidence need. Check whether the answer-bearing passage was indexed, represented with the matching embedding model, eligible for the query and retained for generation. Evaluate retrieval with reviewed query/evidence cases and operational constraints rather than selecting an algorithm from final-answer fluency alone.

**Microsoft Learn**

* [Relevance in vector search](https://learn.microsoft.com/en-us/azure/search/vector-search-ranking)

Source: [AI-300: Designing Vector, Keyword, and Hybrid RAG Retrieval](https://learningpathx.com/news/ai-300-designing-vector-keyword-and-hybrid-rag-retrieval.html)
