from pymilvus import MilvusClient, DataType, Collection, connections
# Setup Milvus client
client = MilvusClient(uri="http://10.104.18.39:19530")
# Create a collection schema with a partition key
schema = client.create_schema(
auto_id=False,
enable_dynamic_field=True,
partition_key_field="color", # Set the field used as the partition key
num_partitions=10 # Specify the number of partitions
)
# Add fields to the 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="color", datatype=DataType.VARCHAR, max_length=512)
# Create the collection with the defined schema
client.create_collection(collection_name="hello_2", schema=schema)
connections.connect(host="10.104.18.39")
c = Collection(name="hello_2")
print(c.partitions)
print(c.describe())
- Hardware/Softward conditions (OS, CPU, GPU, Memory):
- Method of installation (Docker, or from source):
- Milvus version (v0.3.1, or v0.4.0):
- Milvus configuration (Settings you made in `server_config.yaml`):
Is there an existing issue for this?
Describe the bug
pymilvus version: 2.4.0rc39 milvus version: 2.4-20240621-e02a95e3-amd64
result
Expected Behavior
No response
Steps/Code To Reproduce behavior
No response
Environment details
Anything else?
No response