Database / Milvus Vector database Interview questions
What is dynamic schema in Milvus?
Dynamic schema lets a collection accept and store additional key-value fields on each inserted entity beyond what's explicitly declared in the collection's schema, useful when the exact set of metadata fields isn't fully known or fixed ahead of time.
schema = client.create_schema(enable_dynamic_field=True) schema.add_field("id", DataType.INT64, is_primary=True) schema.add_field("embedding", DataType.FLOAT_VECTOR, dim=768) client.create_collection(collection_name="articles", schema=schema) client.insert(collection_name="articles", data=[ {"id": 1, "embedding": [...], "author": "Jane Doe", "views": 1024} ])
Fields like author and views above weren't explicitly declared in the schema but are still stored and queryable because dynamic fields were enabled. This trades some of the strictness and query-planning predictability of a fully fixed schema for flexibility, which suits applications ingesting data with varied or evolving metadata (like articles from different sources with different available fields) without requiring a schema migration every time a new field shows up.
More Related questions...