Fix milvus compatible check error
Browse files- lightrag/kg/milvus_impl.py +16 -6
lightrag/kg/milvus_impl.py
CHANGED
|
@@ -444,7 +444,18 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
|
| 444 |
for field in collection_info.get("fields", []):
|
| 445 |
if field.get("name") == "vector":
|
| 446 |
field_type = field.get("type")
|
| 447 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 448 |
existing_dimension = field.get("params", {}).get("dim")
|
| 449 |
|
| 450 |
if existing_dimension != current_dimension:
|
|
@@ -531,7 +542,9 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
|
| 531 |
# 2. Check schema compatibility
|
| 532 |
self._check_schema_compatibility(collection_info)
|
| 533 |
|
| 534 |
-
logger.info(
|
|
|
|
|
|
|
| 535 |
|
| 536 |
except Exception as e:
|
| 537 |
logger.error(
|
|
@@ -571,16 +584,13 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
|
| 571 |
# Check if our specific collection exists
|
| 572 |
collection_exists = self._client.has_collection(self.namespace)
|
| 573 |
logger.info(
|
| 574 |
-
f"
|
| 575 |
)
|
| 576 |
|
| 577 |
if collection_exists:
|
| 578 |
# Double-check by trying to describe the collection
|
| 579 |
try:
|
| 580 |
self._client.describe_collection(self.namespace)
|
| 581 |
-
logger.info(
|
| 582 |
-
f"Collection '{self.namespace}' confirmed to exist, validating compatibility..."
|
| 583 |
-
)
|
| 584 |
self._validate_collection_compatibility()
|
| 585 |
# Ensure the collection is loaded after validation
|
| 586 |
self._ensure_collection_loaded()
|
|
|
|
| 444 |
for field in collection_info.get("fields", []):
|
| 445 |
if field.get("name") == "vector":
|
| 446 |
field_type = field.get("type")
|
| 447 |
+
|
| 448 |
+
# Extract type name from DataType enum or string
|
| 449 |
+
type_name = None
|
| 450 |
+
if hasattr(field_type, "name"):
|
| 451 |
+
type_name = field_type.name
|
| 452 |
+
elif isinstance(field_type, str):
|
| 453 |
+
type_name = field_type
|
| 454 |
+
else:
|
| 455 |
+
type_name = str(field_type)
|
| 456 |
+
|
| 457 |
+
# Check if it's a vector type (supports multiple formats)
|
| 458 |
+
if type_name in ["FloatVector", "FLOAT_VECTOR"]:
|
| 459 |
existing_dimension = field.get("params", {}).get("dim")
|
| 460 |
|
| 461 |
if existing_dimension != current_dimension:
|
|
|
|
| 542 |
# 2. Check schema compatibility
|
| 543 |
self._check_schema_compatibility(collection_info)
|
| 544 |
|
| 545 |
+
logger.info(
|
| 546 |
+
f"VectorDB Collection '{self.namespace}' compatibility validation passed"
|
| 547 |
+
)
|
| 548 |
|
| 549 |
except Exception as e:
|
| 550 |
logger.error(
|
|
|
|
| 584 |
# Check if our specific collection exists
|
| 585 |
collection_exists = self._client.has_collection(self.namespace)
|
| 586 |
logger.info(
|
| 587 |
+
f"VectorDB collection '{self.namespace}' exists check: {collection_exists}"
|
| 588 |
)
|
| 589 |
|
| 590 |
if collection_exists:
|
| 591 |
# Double-check by trying to describe the collection
|
| 592 |
try:
|
| 593 |
self._client.describe_collection(self.namespace)
|
|
|
|
|
|
|
|
|
|
| 594 |
self._validate_collection_compatibility()
|
| 595 |
# Ensure the collection is loaded after validation
|
| 596 |
self._ensure_collection_loaded()
|