Skip to content

Commit f4a6ea9

Browse files
authored
fix: Milvus multitenancy scalar index creation on Milvus Lite (open-webui#26911)
Enabling ENABLE_MILVUS_MULTITENANCY_MODE with the default MILVUS_URI (embedded Milvus Lite at DATA_DIR/vector_db/milvus.db) fails on the first embedding write: _create_shared_collection calls collection.create_index(RESOURCE_ID_FIELD) with no index params. A Milvus server auto-selects a scalar index type in that case, but Milvus Lite rejects the call with "create_index missing required 'index_type' parameter", so shared collection creation raises and every embedding write 500s (memory add, file upload, knowledge writes). Keep the parameterless call as the first attempt so behavior on Milvus servers is unchanged, fall back to an explicit INVERTED scalar index, and if that also fails log a warning and continue. The scalar index only accelerates resource_id filters; inserts and filtered queries work without it, so a missing index must not break collection creation. Verified against embedded Milvus Lite: shared collections now create (with the warning), and memory add, file upload and memory query succeed end to end. Against a Milvus server the first attempt is identical to the current code, so nothing changes where it works today.
1 parent 0f8846b commit f4a6ea9

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

backend/open_webui/retrieval/vector/dbs/milvus_multitenancy.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,19 @@ def _create_shared_collection(self, mt_collection_name: str, dimension: int):
146146
index_params['params'] = {'nlist': MILVUS_IVF_FLAT_NLIST}
147147

148148
collection.create_index('vector', index_params)
149-
collection.create_index(RESOURCE_ID_FIELD)
149+
try:
150+
# A Milvus server auto-selects the scalar index type; embedded
151+
# Milvus Lite requires an explicit one.
152+
collection.create_index(RESOURCE_ID_FIELD)
153+
except MilvusException:
154+
try:
155+
collection.create_index(RESOURCE_ID_FIELD, {'index_type': 'INVERTED'})
156+
except MilvusException as e:
157+
# The index only accelerates resource_id filters; never fail
158+
# collection creation over it.
159+
log.warning(
160+
f'Could not create {RESOURCE_ID_FIELD} index on {mt_collection_name}: {e}'
161+
)
150162
log.info(f'Created shared collection: {mt_collection_name}')
151163
return collection
152164

0 commit comments

Comments
 (0)