CreateSimpleCollection()
Creates a collection with a simplified schema: one primary-key field and one float vector field.
pub async fn create_collection(&self, request: impl Into<CreateCollectionRequest>) -> Result<()>
Request Syntax
let request = CreateSimpleCollectionRequest::builder()
.collection_name("quick_setup")
.dimension(128)
.metric_type(MetricType::Cosine)
.build()?;
The CreateSimpleCollectionRequest is converted into a CreateCollectionRequest before dispatch, so it is passed to the same create_collection method.
REQUEST FIELDS:
database_name: Option<String>Name of the target database; uses the default database when empty.
collection_name: StringName of the collection to create. Required.
dimension: u32Dimension of the float vector field. Must be greater than zero.
primary_field: StringName of the primary-key field. Defaults to
id.primary_field_type: DataTypeData type of the primary key; must be
Int64orVarChar. Defaults toInt64. See DataType.id_type: Option<String>Raw alias for the primary-key type:
intmaps toInt64,stringorstrmaps toVarChar.max_length: u32Maximum length of a
VarCharprimary key. Defaults to65535.vector_field: StringName of the float vector field. Defaults to
vector.auto_id: boolWhether primary keys are auto-generated. Defaults to
false.enable_dynamic_field: boolWhether dynamic fields are enabled. Defaults to
true.consistency_level: ConsistencyLevelDefault consistency level for reads on the collection. Defaults to
Bounded. See ConsistencyLevel.metric_type: MetricTypeMetric type used by the AutoIndex created on the vector field. Defaults to
Cosine. See MetricType.num_shards: i32Number of shards for the collection. Defaults to
1.num_partitions: i64Number of partitions to create. Defaults to
0.properties: HashMap<String, String>Collection properties.
description: Option<String>Optional description of the collection.
RETURN TYPE:
Result<()>
RETURNS:
Returns an empty result indicating success. Returns Error on failure.
Example
let request = CreateSimpleCollectionRequest::builder()
.collection_name("quick_setup")
.dimension(128)
.metric_type(MetricType::Cosine)
.build()?;
client.create_collection(request).await?;