Database / Milvus Vector database Interview questions
What is a scalar field in Milvus, and how is it used with vector search?
A scalar field holds ordinary, non-vector data, strings, integers, booleans, JSON, and so on, defined alongside a collection's vector field(s). Scalar fields let a search combine vector similarity with traditional filtering conditions in a single query, rather than requiring similarity search and filtering to happen as two separate, disconnected steps.
results = client.search( collection_name="products", data=[query_vector], filter="category == 'electronics' and price < 500", limit=10 )
This combined approach, often called filtered or hybrid vector search, is what makes queries like "find products similar to this one, but only in stock and under $500" possible in a single request, with the scalar filter applied alongside (rather than after) the vector similarity ranking, which is both more efficient and more correct than searching broadly and filtering the results afterward, since post-filtering can return fewer results than requested if too many top matches get filtered out.
More Related questions...