I am experiencing a persistent issue when I attempt to insert data into a Milvus partition using the data and schema shown below. I keep receiving a DataTypeNotSupportException error. I believe I have carefully followed the documentation and making sure my data matches the expected format, but the error still exists.
I have attached my code for reference:
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
I am wondering if anyone has encountered similar issue and would be able to guide me through this problem. Thanks!
I tried removing the line
connections.connect(host=MILVUS_SETTINGS['host'], port=MILVUS_SETTINGS['port'])
and no exception is being thrown. The full code looks like the following:
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)