milvus null and default value functionality is not working #38346
Unanswered
vihariazure
asked this question in
Q&A and General discussion
Replies: 1 comment 5 replies
-
I guess your milvus server is not v2.5.0. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
https://milvus.io/docs/nullable-and-default.md
hi team i tired with above code regarding using none values
from pymilvus import MilvusClient, DataType
client = MilvusClient(uri='http://localhost:19530')
schema = client.create_schema()
schema.add_field(field_name="id", datatype=DataType.INT64, is_primary=True)
schema.add_field(field_name="vector", datatype=DataType.FLOAT_VECTOR, dim=5)
schema.add_field(field_name="age", datatype=DataType.INT64, nullable=True) # Nullable field
index_params = client.prepare_index_params()
index_params.add_index(field_name="vector", index_type="IVF_FLAT", metric_type="L2", params={ "nlist": 128 })
client.create_collection(collection_name="user_profiles_null", schema=schema, index_params=index_params)
data = [
{"id": 1, "vector": [0.1, 0.2, 0.3, 0.4, 0.5], "age": 30},
{"id": 2, "vector": [0.2, 0.3, 0.4, 0.5, 0.6], "age": None},
]
client.insert(collection_name="user_profiles_null", data=data)
below is the error
File d:\milvus_connect\milvus\lib\site-packages\pymilvus\client\entity_helper.py:264, in pack_field_value_to_field_data(field_value, field_data, field_info)
262 field_data.scalars.long_data.data.append(field_value)
263 except (TypeError, ValueError) as e:
--> 264 raise DataNotMatchException(
265 message=ExceptionsMessage.FieldDataInconsistent
266 % (field_name, "int64", type(field_value))
267 ) from e
268 elif field_type == DataType.FLOAT:
269 try:
DataNotMatchException: <DataNotMatchException: (code=1, message=The Input data type is inconsistent with defined schema, {age} field should be a int64, but got a {<class 'NoneType'>} instead.)>
Beta Was this translation helpful? Give feedback.
All reactions