Milvus 中的DataTypeNotSupportException

问题描述 投票:0回答:1

当我尝试使用如下所示的数据和架构将数据插入 Milvus 分区时,遇到了一个持续存在的问题。我不断收到 DataTypeNotSupportException 错误。我相信我已仔细遵循文档并确保我的数据符合预期格式,但错误仍然存在。

我已附上我的代码以供参考:

from pymilvus import FieldSchema, CollectionSchema, DataType, connections

id_field = FieldSchema(name="id", dtype=DataType.INT64, is_primary=True)
vector_field = FieldSchema(name="text_vector", dtype=DataType.FLOAT_VECTOR, dim=768)

schema = CollectionSchema(fields=[id_field, vector_field])
connections.connect(host=MILVUS_SETTINGS['host'], port=MILVUS_SETTINGS['port'])

milvus_collection = Collection(name="test_collection_name", schema=schema)
milvus_partition=Partition(milvus_collection, "test_partition_name")

unique_id = 1
text_vector = [0.1] * 768  # Make sure this has exactly 768 floats

# Option 1
data = {
    "id": [unique_id, unique_id + 1],  # List of IDs
    "text_vector": [text_vector, text_vector]  # List of vectors
}
milvus_partition.insert(data=data)
 --> Error during insert: <DataTypeNotSupportException: (code=0, message=Data type is not support.)>

# Option 2
data = [{
    "id": [unique_id, unique_id + 1],  # List of IDs
    "text_vector": [text_vector, text_vector]  # List of vectors
}]
milvus_partition.insert(data=data)
---> /.local/lib/python3.10/site-packages/pymilvus/orm/prepare.py", line 60, in prepare_insert_data
    if isinstance(data[i], numpy.ndarray):
IndexError: list index out of range

我想知道是否有人遇到过类似的问题并且能够指导我解决这个问题。谢谢!

exception schema vector-database milvus
1个回答
0
投票

我尝试删除线

connections.connect(host=MILVUS_SETTINGS['host'], port=MILVUS_SETTINGS['port'])

并且没有抛出任何异常。完整代码如下所示:

id_field = FieldSchema(name="id", dtype=DataType.INT64, is_primary=True)
vector_field = FieldSchema(name="text_vector", dtype=DataType.FLOAT_VECTOR, dim=768)

schema = CollectionSchema(fields=[id_field, vector_field])
connections.connect(host=MILVUS_SETTINGS['host'], port=MILVUS_SETTINGS['port'])

milvus_collection = Collection(name="test_collection_name", schema=schema)
milvus_partition = Partition(milvus_collection, "test_partition_name")

unique_id = 1
text_vector = [0.1] * 768  # Make sure this has exactly 768 floats

###### Option 1 #######
data = [
    [unique_id, unique_id + 1],  # List of IDs
    [text_vector, text_vector]  # List of vectors
]
milvus_partition.insert(data=data)
© www.soinside.com 2019 - 2024. All rights reserved.