enhance: [2.5][GoSDK] Add WithEnableMatch syntactic sugar (#39837) (#39853)

Cherry-pick from master
pr: #39837
Related to #35922

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/39839/head
congqixia 2025-02-13 19:28:15 +08:00 committed by GitHub
parent 16ea4fcb90
commit aa74e8ba3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 1 deletions

View File

@ -388,6 +388,14 @@ func (f *Field) WithAnalyzerParams(params map[string]any) *Field {
return f
}
func (f *Field) WithEnableMatch(enable bool) *Field {
if f.TypeParams == nil {
f.TypeParams = make(map[string]string)
}
f.TypeParams[TypeParamEnableMatch] = strconv.FormatBool(enable)
return f
}
// ReadProto parses FieldSchema
func (f *Field) ReadProto(p *schemapb.FieldSchema) *Field {
f.ID = p.GetFieldID()

View File

@ -29,7 +29,7 @@ func TestFieldSchema(t *testing.T) {
NewField().WithName("partition_key").WithDataType(FieldTypeInt32).WithIsPartitionKey(true),
NewField().WithName("array_field").WithDataType(FieldTypeArray).WithElementType(FieldTypeBool).WithMaxCapacity(128),
NewField().WithName("clustering_key").WithDataType(FieldTypeInt32).WithIsClusteringKey(true),
NewField().WithName("varchar_text").WithDataType(FieldTypeVarChar).WithMaxLength(65535).WithEnableAnalyzer(true).WithAnalyzerParams(map[string]any{}),
NewField().WithName("varchar_text").WithDataType(FieldTypeVarChar).WithMaxLength(65535).WithEnableAnalyzer(true).WithAnalyzerParams(map[string]any{}).WithEnableMatch(true),
NewField().WithName("default_value_bool").WithDataType(FieldTypeBool).WithDefaultValueBool(true),
NewField().WithName("default_value_int").WithDataType(FieldTypeInt32).WithDefaultValueInt(1),

View File

@ -33,6 +33,9 @@ const (
// TypeParamMaxCapacity is the const for array type max capacity
TypeParamMaxCapacity = `max_capacity`
// TypeParamEnableMatch is the const for enable text match
TypeParamEnableMatch = `enable_match`
// ClStrong strong consistency level
ClStrong ConsistencyLevel = ConsistencyLevel(commonpb.ConsistencyLevel_Strong)
// ClBounded bounded consistency level with default tolerance of 5 seconds