---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://mixpeek.com/.well-known/search?q={query}"
  method: GET
  documentation: "https://mixpeek.com/llms.txt"
---

1.  [](/)
2.  [Glossary](/glossary)
3.  HNSW (Hierarchical Navigable Small World)

[Back to Glossary](/glossary)

# What is HNSW (Hierarchical Navigable Small World)

## HNSW (Hierarchical Navigable Small World) - Graph-based approximate nearest neighbor search algorithm

A high-performance graph-based ANN algorithm that builds a multi-layered navigable small world graph for fast similarity search. HNSW is the default index type in most modern vector databases used for multimodal retrieval.

### How It Works

HNSW constructs a hierarchical graph where each layer is a navigable small world network with decreasing density. The top layers contain few nodes with long-range connections for fast coarse navigation, while the bottom layer contains all nodes with short-range connections for precise search. Query traversal starts at the top layer and greedily descends, narrowing the search region at each level.

### Technical Details

Key parameters include M (number of connections per node, typically 16-64), ef\_construction (search width during build, typically 100-500), and ef\_search (search width during query, typically 50-500). Higher M and ef values improve recall but increase memory and latency. The algorithm achieves logarithmic search complexity with respect to dataset size, making it efficient even at billion-scale.

### Best Practices

*   Start with M=16 and ef\_construction=200 as reasonable defaults, then tune based on benchmarks
*   Set ef\_search dynamically based on the required recall level for each query
*   Use separate read and write threads since HNSW supports concurrent reads but serializes writes
*   Monitor memory usage carefully as HNSW indices can be 1.5-2x the raw vector data size

### Common Pitfalls

*   Setting M too low, resulting in disconnected graph regions and poor recall
*   Using ef\_search lower than the number of requested results k
*   Not reserving enough memory for the graph structure on top of vector storage
*   Expecting real-time updates at high throughput without understanding write serialization

### Advanced Tips

*   Combine HNSW with product quantization to reduce memory while maintaining graph navigation quality
*   Use HNSW with scalar quantization (SQ8) for a good balance of memory savings and recall
*   Implement filtered HNSW search by pruning graph traversal based on metadata predicates
*   Consider segment-based HNSW implementations that allow efficient deletions and updates

[One-click templatesStart from a templateEach template deploys a working search app on your own files.Browse templates](/templates)

[Put it to work: search your own files](https://studio.mixpeek.com/namespaces/create?mode=managed&utm_source=homepage&utm_medium=glossary_onramp&utm_campaign=mvs_onramp)

### Related Terms

[ACID](/glossary/acid)[API](/glossary/api)[Blob Storage](/glossary/blob-storage)[CLIP](/glossary/clip)[Embedding](/glossary/embedding)