milvus-logo
LFAI
< Docs
  • Java
    • v2

CollectionSchema

A CollectionSchema instance represents the schema of a collection. A schema sketches the structure of a collection.

io.milvus.v2.service.collection.request.CreateCollectionReq.CollectionSchema

Constructor

Constructs the schema of a collection by defining fields, data types, and other parameters.

CreateCollectionReq.CollectionSchema.builder()
    .fieldSchemaList(List<CreateCollectionReq.FieldSchema>)
    .build();

BUILDER METHODS:

  • fieldSchemaList(List<CreateCollectionReq.FieldSchema>)

    A list of FieldSchema objects that define the fields in the collection schema.

    what is a field schema?

    A field schema represents and contains metadata for a single field, while CollectionSchema ties together a list of FieldSchema objects to define the full schema.

RETURN TYPE:

CollectionSchema

RETURNS:

A CollectionSchema object.

EXCEPTIONS:

  • MilvusClientExceptions

    This exception will be raised when any error occurs during this operation.

Example

// define a Collection Schema
CreateCollectionReq.CollectionSchema collectionSchema = client.createSchema();
// add two fileds, id and vector
collectionSchema.addField(AddFieldReq.builder().fieldName("id").dataType(DataType.Int64).isPrimaryKey(Boolean.TRUE).autoID(Boolean.FALSE).description("id").build());
collectionSchema.addField(AddFieldReq.builder().fieldName("vector").dataType(DataType.FloatVector).dimension(dim).build());

Methods

The following are the methods of the CollectionSchema class: