Skip to content

Commit

Permalink
Enable dynamic schema for high-level newcollection by default (#506)
Browse files Browse the repository at this point in the history
Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia authored Jun 29, 2023
1 parent 0e14519 commit 41998f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion client/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func (c *GrpcClient) NewCollection(ctx context.Context, collName string, dimensi
VectorFieldName: "vector",
MetricsType: entity.IP,
AutoID: false,
EnableDynamicSchema: true,
}

for _, o := range opts {
Expand All @@ -124,7 +125,7 @@ func (c *GrpcClient) NewCollection(ctx context.Context, collName string, dimensi
pkField = pkField.WithMaxLength(opt.PrimaryKeyMaxLength)
}

sch := entity.NewSchema().WithName(collName).WithAutoID(opt.AutoID).
sch := entity.NewSchema().WithName(collName).WithAutoID(opt.AutoID).WithDynamicFieldEnabled(opt.EnableDynamicSchema).
WithField(pkField).
WithField(entity.NewField().WithName(opt.VectorFieldName).WithDataType(entity.FieldTypeFloatVector).WithDim(dimension))

Expand Down
7 changes: 7 additions & 0 deletions client/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type createCollOpt struct {
VectorFieldName string
MetricsType entity.MetricType
AutoID bool
EnableDynamicSchema bool
}

func WithPKFieldName(name string) CreateCollectionOption {
Expand Down Expand Up @@ -69,6 +70,12 @@ func WithAutoID(autoID bool) CreateCollectionOption {
}
}

func WithEnableDynamicSchema(enable bool) CreateCollectionOption {
return func(opt *createCollOpt) {
opt.EnableDynamicSchema = enable
}
}

// WithConsistencyLevel specifies a specific ConsistencyLevel, rather than using the default ReaderProperties.
func WithConsistencyLevel(cl entity.ConsistencyLevel) CreateCollectionOption {
return func(opt *createCollOpt) {
Expand Down

0 comments on commit 41998f4

Please sign in to comment.