Database / Milvus Vector database Interview questions
What is an index in Milvus, and why is it needed?
An index in Milvus is a specialized data structure built over a vector field that dramatically speeds up similarity search by avoiding a brute-force comparison against every single stored vector. Without an index, finding the nearest neighbors of a query vector requires computing the distance to every vector in the collection, which becomes prohibitively slow as a collection grows into the millions or billions of entries.
index_params = client.prepare_index_params() index_params.add_index( field_name="embedding", index_type="HNSW", metric_type="COSINE", params={"M": 16, "efConstruction": 200} ) client.create_index(collection_name="products", index_params=index_params)
Indexes trade a small amount of accuracy (they perform approximate, not exact, nearest neighbor search) for a large gain in speed, which is an acceptable and often necessary trade-off for most real-world similarity search applications, where finding a highly relevant result quickly matters more than guaranteeing the mathematically exact single closest match every time.
More Related questions...