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:
parent
7184c7b3ab
commit
14d9fe49b0
1 changed files with 0 additions and 23 deletions
|
|
@ -44,12 +44,6 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
||||||
max_length=512,
|
max_length=512,
|
||||||
nullable=True,
|
nullable=True,
|
||||||
),
|
),
|
||||||
FieldSchema(
|
|
||||||
name="entity_type",
|
|
||||||
dtype=DataType.VARCHAR,
|
|
||||||
max_length=128,
|
|
||||||
nullable=True,
|
|
||||||
),
|
|
||||||
FieldSchema(
|
FieldSchema(
|
||||||
name="file_path",
|
name="file_path",
|
||||||
dtype=DataType.VARCHAR,
|
dtype=DataType.VARCHAR,
|
||||||
|
|
@ -67,7 +61,6 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
||||||
FieldSchema(
|
FieldSchema(
|
||||||
name="tgt_id", dtype=DataType.VARCHAR, max_length=512, nullable=True
|
name="tgt_id", dtype=DataType.VARCHAR, max_length=512, nullable=True
|
||||||
),
|
),
|
||||||
FieldSchema(name="weight", dtype=DataType.DOUBLE, nullable=True),
|
|
||||||
FieldSchema(
|
FieldSchema(
|
||||||
name="file_path",
|
name="file_path",
|
||||||
dtype=DataType.VARCHAR,
|
dtype=DataType.VARCHAR,
|
||||||
|
|
@ -227,19 +220,6 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
||||||
logger.debug(f"IndexParams method failed for entity_name: {e}")
|
logger.debug(f"IndexParams method failed for entity_name: {e}")
|
||||||
self._create_scalar_index_fallback("entity_name", "INVERTED")
|
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():
|
elif "relationships" in self.namespace.lower():
|
||||||
# Create indexes for relationship fields
|
# Create indexes for relationship fields
|
||||||
try:
|
try:
|
||||||
|
|
@ -294,7 +274,6 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
||||||
# Create scalar indexes using fallback
|
# Create scalar indexes using fallback
|
||||||
if "entities" in self.namespace.lower():
|
if "entities" in self.namespace.lower():
|
||||||
self._create_scalar_index_fallback("entity_name", "INVERTED")
|
self._create_scalar_index_fallback("entity_name", "INVERTED")
|
||||||
self._create_scalar_index_fallback("entity_type", "INVERTED")
|
|
||||||
elif "relationships" in self.namespace.lower():
|
elif "relationships" in self.namespace.lower():
|
||||||
self._create_scalar_index_fallback("src_id", "INVERTED")
|
self._create_scalar_index_fallback("src_id", "INVERTED")
|
||||||
self._create_scalar_index_fallback("tgt_id", "INVERTED")
|
self._create_scalar_index_fallback("tgt_id", "INVERTED")
|
||||||
|
|
@ -320,14 +299,12 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
||||||
if "entities" in self.namespace.lower():
|
if "entities" in self.namespace.lower():
|
||||||
specific_fields = {
|
specific_fields = {
|
||||||
"entity_name": {"type": "VarChar"},
|
"entity_name": {"type": "VarChar"},
|
||||||
"entity_type": {"type": "VarChar"},
|
|
||||||
"file_path": {"type": "VarChar"},
|
"file_path": {"type": "VarChar"},
|
||||||
}
|
}
|
||||||
elif "relationships" in self.namespace.lower():
|
elif "relationships" in self.namespace.lower():
|
||||||
specific_fields = {
|
specific_fields = {
|
||||||
"src_id": {"type": "VarChar"},
|
"src_id": {"type": "VarChar"},
|
||||||
"tgt_id": {"type": "VarChar"},
|
"tgt_id": {"type": "VarChar"},
|
||||||
"weight": {"type": "Double"},
|
|
||||||
"file_path": {"type": "VarChar"},
|
"file_path": {"type": "VarChar"},
|
||||||
}
|
}
|
||||||
elif "chunks" in self.namespace.lower():
|
elif "chunks" in self.namespace.lower():
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue