Open bdockbockd opened 1 month ago
hi @bdockbockd , can you provide the code?
Here is my relevant code
self.client = MilvusClient(f'milvus_demo.db')
def create_index(self, collection_name):
"""Create an index on the sparse vector field."""
index_params = self.client.prepare_index_params()
index_params.add_index(
field_name="sparse_vector",
index_name="sparse_inverted_index",
index_type="SPARSE_WAND",
metric_type="IP",
params={"drop_ratio_build": 0.2}
)
**self.client.create_index(collection_name=collection_name, index_params=index_params)** << errror
Meaningful throw
74 collection_meta.cpp:148] [SERVER][CreateIndex][grpcpp_sync_ser] Add index failed, err: unrecognized token: "�"
RPC error: [create_index], <MilvusException: (code=5, message=: internal error)>, <Time:{'RPC start': '2024-10-08 15:08:18.884977', 'RPC error': '2024-10-08 15:08:18.886644'}>
Failed to create an index on collection
My schema
def create_collection(self, collection_name):
"""Create a collection with a schema including a sparse vector field."""
schema = self.client.create_schema(
auto_id=True,
enable_dynamic_fields=True,
)
schema.add_field(field_name="pk", datatype=DataType.VARCHAR, is_primary=True, max_length=100)
schema.add_field(field_name="uid", datatype=DataType.VARCHAR, max_length=100)
schema.add_field(field_name="number", datatype=DataType.DOUBLE)
schema.add_field(field_name="sparse_vector", datatype=DataType.SPARSE_FLOAT_VECTOR)
self.client.create_collection(collection_name=collection_name, schema=schema)
Before create_index
operation, data seems to insert just fine
It may be because your collection_name is illegal. The following code can run normally.
from pymilvus import MilvusClient, DataType
milvus_client = MilvusClient(f'milvus_demo.db')
collection_name="my_collection"
schema = milvus_client.create_schema(
auto_id=True,
enable_dynamic_fields=True,
)
schema.add_field(field_name="pk", datatype=DataType.VARCHAR, is_primary=True, max_length=100)
schema.add_field(field_name="uid", datatype=DataType.VARCHAR, max_length=100)
schema.add_field(field_name="number", datatype=DataType.DOUBLE)
schema.add_field(field_name="sparse_vector", datatype=DataType.SPARSE_FLOAT_VECTOR)
milvus_client.create_collection(collection_name=collection_name, schema=schema)
index_params = milvus_client.prepare_index_params()
index_params.add_index(
field_name="sparse_vector",
index_name="sparse_inverted_index",
index_type="SPARSE_WAND",
metric_type="IP",
params={"drop_ratio_build": 0.2}
)
milvus_client.create_index(collection_name=collection_name, index_params=index_params)
print(milvus_client.list_indexes(collection_name=collection_name))
Environment Base image: python=3.8.5