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