You insert a batch of embeddings into Milvus and search for one of them right away. It's not there. A few seconds later it is. Or the search fails outright:
MilvusException: (code=101, message=failed to search: collection not loaded)
Both are among the most common questions from new Milvus users, and both come from how Milvus separates writing, indexing and serving data.
Problem 1: "collection not loaded"
Milvus only searches collections that are loaded into query nodes' memory. Creating a collection and inserting data doesn't load it.
from pymilvus import MilvusClient
client = MilvusClient(uri="http://localhost:19530")
client.create_index("docs", index_params) # an index on the vector field is required
client.load_collection("docs") # make it searchable
print(client.get_load_state("docs")) # expect: Loaded
Notes:
- The quick-setup path (
create_collectionwith just a dimension) creates an index and loads the collection for you. Custom schemas usually don't, so you have to index and load explicitly. - A vector field needs an index before loading (for example
AUTOINDEX,HNSWorIVF_FLAT). - Loading uses memory (or disk, with mmap or DiskANN), so release collections you're not querying:
client.release_collection("old_docs"). - After adding fields or partitions, or restarting a cluster without auto-load, check the load state again.
Problem 2: new data isn't found right away
Milvus is distributed: inserts go through a log (message queue), and query nodes consume that log to serve growing segments that contain recent data. A search has to decide how up to date its view must be. That's the :
