weaviate-python-client icon indicating copy to clipboard operation
weaviate-python-client copied to clipboard

Throw error message when trying to update vector index type configuration in a collection

Open rthiiyer82 opened this issue 2 years ago • 1 comments

Background: I have been running latency tests to compare results of hnsw, flat and dynamic vector indexes. While inserting objects I realised , I had incorrectly configured the collection to flat when I had to configure it to dynamic index. I tried to update the vector index config in the collection using the following python code. The script did not throw any error. However, the vector index did not update to dynamic . It continued showing flat index.

from weaviate.classes.config import Reconfigure

# Get the Article collection object
dynamicTestCollection = client.collections.get("Testingdynamicindexings")

# Update the collection configuration
dynamicTestCollection.config.update(
    vectorizer_config= Reconfigure.VectorIndex.dynamic()
)

Actual result: The client did not throw error message stating that vector index cannot be updated from hnsw or flat or dynamic

Expected result: The client should throw an error. Vector index type cannot be changed by changing the config. The objects have be to fully reindex (unfortunately).

rthiiyer82 avatar Sep 04 '24 10:09 rthiiyer82

Hi — I'd like to pick this up.

Root cause: in _CollectionConfigUpdate.merge_with_existing the vector-index update branches merge the new vectorIndexConfig into the existing schema but never validate that the requested index type matches the existing one. For the legacy single-vector path vectorIndexType is left untouched (so a flat → dynamic reconfigure silently no-ops, exactly as reported), and for named vectors the type label is overwritten without the server-side reindex actually happening.

Proposed fix: detect an attempt to change the (immutable) vectorIndexType across all three update paths (vector_index_config, vectorizer_config, and vector_config) and raise WeaviateInvalidInputError with a clear message that the type is immutable and the collection must be recreated/reindexed. Adding unit tests in test/collection/test_config_update.py that assert the raise and that same-type updates still succeed. PR incoming.

shaikn6 avatar Jun 25 '26 14:06 shaikn6