创建、删除集合

本页提供创建或删除集合的 Python 示例代码。

参考 示例程序 获取更详细的使用方式。

创建集合

  1. 准备创建集合所需参数:

    1. # Prepare collection parameters.
    2. # create collection name
    3. >>> param = {'collection_name':'test01', 'dimension':256, 'segment_row_limit':1024, 'metric_type':MetricType.L2} >>> collection_name = 'test01'
    4. # Create a collection of 4 fields, where fields A, B, and C are int type fields
    5. # and Vec is a 128-dimension float vector field.
    6. # The default value of segment_row_limit is 524288 if not specified.
    7. # If you set auto_id to True, you have Milvus create entity IDs.
    8. >>> collection_param = {
    9. ... "fields": [
    10. ... {"name": "A", "type": DataType.INT32},
    11. ... {"name": "B", "type": DataType.INT32},
    12. ... {"name": "C", "type": DataType.INT64},
    13. ... {"name": "Vec", "type": DataType.FLOAT_VECTOR, "params": {"dim": 128}}
    14. ... ],
    15. ... "segment_row_limit": 100000,
    16. ... "auto_id": True
    17. ... }
  2. 创建集合名为 test01 的集合:

    1. # Create a collection.
    2. >>> client.create_collection('test01', collection_param)

删除集合

  1. # Drop a collection.
  2. >>> milvus.drop_collection('test01')

常见问题

建立集合后,segment_row_limitmetric_type 还支持修改吗? 不支持。 Milvus 对集合和分区的总数有限制吗? 有。二者之和不能超过 4,096。