milvus-logo
LFAI
< Docs
  • Python
    • Schema

CollectionSchema()

This is the constructor method to create a CollectionSchema.

Invocation

CollectionSchema(fields, description='', **kwargs)

Return

A CollectionSchema object.

Properties

PropertyDescription
fieldsList of FieldSchema
descriptionDescription of the CollectionSchema
auto_idBoolean value that indicates if the primary keys are automatically generated
enable_dynamic_fieldBoolean value that indicates whether to use dynamic fields in the collection

Example

from pymilvus import CollectionSchema, FieldSchema, DataType

book_id = FieldSchema(
  name="book_id", 
  dtype=DataType.INT64, 
  is_primary=True, 
)

word_count = FieldSchema(
  name="word_count", 
  dtype=DataType.INT64,  
)

book_intro = FieldSchema(
  name="book_intro", 
  dtype=DataType.FLOAT_VECTOR, 
  dim=2
)

schema = CollectionSchema(
  fields=[book_id, word_count, book_intro], 
  description="Test book search",
  enable_dynamic_field=True
)
Feedback

Was this page helpful?