Skip to main content
Learn how to optimize search performance for your use case.

Use Appropriate topK

Request only as many results as you need:
src/performance-topk.ts

Use Filters to Reduce Search Space

Apply metadata filters to narrow results:
src/performance-filters.ts

Enable HNSW for Large Datasets

For datasets > 10,000 documents, enable HNSW indexing:
src/performance-hnsw.ts

Performance Comparison

See HNSW Scaling for details.

Query Caching

Cache frequent queries for better performance:
src/query-caching.ts

Warmup Queries

Run a warmup query during startup to optimize the embedding pipeline:
src/warmup.ts

Batch Similar Queries

If you need to run multiple searches with the same query:
src/batch-queries.ts

Monitoring Search Performance

src/performance-monitoring.ts

Performance Checklist

1

Use appropriate topK

Don’t request more results than you need
2

Apply metadata filters

Reduce the search space with filters
3

Enable HNSW for scale

Use HNSW indexing for > 10,000 documents
4

Cache frequent queries

Implement query caching for repeated searches
5

Warmup on startup

Run a warmup query to optimize the pipeline

HNSW Overview

Scale with HNSW

HNSW Tuning

Tune HNSW parameters

Basic Search

Search fundamentals