refactor(milvus): remove entity_type and weight fields from schema

- Remove entity_type field from entities collections
- Remove weight field from relationships collections
- Update schema definitions and index creation logic
- Maintain backward compatibility with existing data via dynamic fields
This commit is contained in:
yangdx 2025-07-17 12:08:35 +08:00
parent 7184c7b3ab
commit 14d9fe49b0

View File

@ -44,12 +44,6 @@ class MilvusVectorDBStorage(BaseVectorStorage):
max_length=512,
nullable=True,
),
FieldSchema(
name="entity_type",
dtype=DataType.VARCHAR,
max_length=128,
nullable=True,
),
FieldSchema(
name="file_path",
dtype=DataType.VARCHAR,
@ -67,7 +61,6 @@ class MilvusVectorDBStorage(BaseVectorStorage):
FieldSchema(
name="tgt_id", dtype=DataType.VARCHAR, max_length=512, nullable=True
),
FieldSchema(name="weight", dtype=DataType.DOUBLE, nullable=True),
FieldSchema(
name="file_path",
dtype=DataType.VARCHAR,
@ -227,19 +220,6 @@ class MilvusVectorDBStorage(BaseVectorStorage):
logger.debug(f"IndexParams method failed for entity_name: {e}")
self._create_scalar_index_fallback("entity_name", "INVERTED")
try:
entity_type_index = self._get_index_params()
entity_type_index.add_index(
field_name="entity_type", index_type="INVERTED"
)
self._client.create_index(
collection_name=self.namespace,
index_params=entity_type_index,
)
except Exception as e:
logger.debug(f"IndexParams method failed for entity_type: {e}")
self._create_scalar_index_fallback("entity_type", "INVERTED")
elif "relationships" in self.namespace.lower():
# Create indexes for relationship fields
try:
@ -294,7 +274,6 @@ class MilvusVectorDBStorage(BaseVectorStorage):
# Create scalar indexes using fallback
if "entities" in self.namespace.lower():
self._create_scalar_index_fallback("entity_name", "INVERTED")
self._create_scalar_index_fallback("entity_type", "INVERTED")
elif "relationships" in self.namespace.lower():
self._create_scalar_index_fallback("src_id", "INVERTED")
self._create_scalar_index_fallback("tgt_id", "INVERTED")
@ -320,14 +299,12 @@ class MilvusVectorDBStorage(BaseVectorStorage):
if "entities" in self.namespace.lower():
specific_fields = {
"entity_name": {"type": "VarChar"},
"entity_type": {"type": "VarChar"},
"file_path": {"type": "VarChar"},
}
elif "relationships" in self.namespace.lower():
specific_fields = {
"src_id": {"type": "VarChar"},
"tgt_id": {"type": "VarChar"},
"weight": {"type": "Double"},
"file_path": {"type": "VarChar"},
}
elif "chunks" in self.namespace.lower():