bugfix
This commit is contained in:
parent
f50ed1042e
commit
062a5f4371
@ -8,6 +8,9 @@ class BaseVDB:
|
||||
output_fields=None):
|
||||
pass
|
||||
|
||||
def get_db_type(dtype: str):
|
||||
return self.dbtypes.get(dtype)
|
||||
|
||||
def upsert(self, collection_name, data_dicts, partition_name=None):
|
||||
pass
|
||||
|
||||
|
||||
@ -10,7 +10,15 @@ from pymilvus import (
|
||||
class MilvusManager(BaseVDB):
|
||||
_instance = None
|
||||
_lock = Lock()
|
||||
|
||||
dbtypes = {
|
||||
"str": DataType.VARCHAR,
|
||||
"int": DataType.INT32,
|
||||
"bool": DataType.BOOL,
|
||||
"float": DataType.FLOAT,
|
||||
"fvector": DataType.FLOAT_VECTOR,
|
||||
"bvector": DataType.BINARY_VECTOR,
|
||||
"json": DataType.JSON
|
||||
}
|
||||
def __new__(cls):
|
||||
with cls._lock:
|
||||
if cls._instance is None:
|
||||
@ -67,7 +75,7 @@ class MilvusManager(BaseVDB):
|
||||
for cfg in fields_config:
|
||||
field = FieldSchema(
|
||||
name=cfg['name'],
|
||||
dtype=cfg['type'],
|
||||
dtype=self.get_db_type(cfg['type']),
|
||||
is_primary=cfg.get('is_primary', False),
|
||||
auto_id=cfg.get('auto_id', False),
|
||||
dim=cfg.get('dim'),
|
||||
@ -80,7 +88,8 @@ class MilvusManager(BaseVDB):
|
||||
|
||||
# 自动为向量字段创建索引 (内网推荐 HNSW)
|
||||
for cfg in fields_config:
|
||||
if cfg['type'] in [DataType.FLOAT_VECTOR, DataType.BINARY_VECTOR]:
|
||||
dbtype = self.get_db_type(cfg['type'])
|
||||
if dbtype in [DataType.FLOAT_VECTOR, DataType.BINARY_VECTOR]:
|
||||
index_params = {
|
||||
"metric_type": "L2",
|
||||
"index_type": "HNSW",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user