diff --git a/internal/proxy/task_index.go b/internal/proxy/task_index.go index 670647fa16..80a27b68c3 100644 --- a/internal/proxy/task_index.go +++ b/internal/proxy/task_index.go @@ -346,10 +346,6 @@ func (cit *createIndexTask) parseIndexParams(ctx context.Context) error { config = Params.AutoIndexConfig.SparseIndexParams.GetAsJSONMap() } else if typeutil.IsBinaryVectorType(cit.fieldSchema.DataType) { if metricTypeExist && funcutil.SliceContain(indexparamcheck.DeduplicateMetrics, metricType) { - if !Params.AutoIndexConfig.EnableDeduplicateIndex.GetAsBool() { - log.Ctx(ctx).Warn("Deduplicate index is not enabled, but metric type is deduplicate.") - return merr.WrapErrParameterInvalidMsg("Deduplicate index is not enabled, but metric type is deduplicate.") - } config = Params.AutoIndexConfig.DeduplicateIndexParams.GetAsJSONMap() } else { // override binary vector index params by autoindex diff --git a/internal/proxy/task_index_test.go b/internal/proxy/task_index_test.go index 7dabcdf4a5..22808dac58 100644 --- a/internal/proxy/task_index_test.go +++ b/internal/proxy/task_index_test.go @@ -398,6 +398,96 @@ func Test_sparse_parseIndexParams(t *testing.T) { }) } +func Test_deduplicate_parseIndexParams(t *testing.T) { + createTestIndexTask := func() *createIndexTask { + return &createIndexTask{ + req: &milvuspb.CreateIndexRequest{ + ExtraParams: []*commonpb.KeyValuePair{ + {Key: MetricTypeKey, Value: "MHJACCARD"}, + }, + }, + fieldSchema: &schemapb.FieldSchema{ + FieldID: 101, + Name: "FieldID", + DataType: schemapb.DataType_BinaryVector, + TypeParams: []*commonpb.KeyValuePair{ + {Key: MetricTypeKey, Value: "MHJACCARD"}, + {Key: DimKey, Value: "128"}, + }, + }, + } + } + + t.Run("disable autoindex", func(t *testing.T) { + cit1 := createTestIndexTask() + paramtable.Init() + Params.Save(Params.AutoIndexConfig.Enable.Key, "false") + defer Params.Reset(Params.AutoIndexConfig.Enable.Key) + + err := cit1.parseIndexParams(context.TODO()) + assert.NoError(t, err) + + assert.ElementsMatch(t, + []*commonpb.KeyValuePair{ + { + Key: common.IndexTypeKey, + Value: "MINHASH_LSH", + }, + { + Key: MetricTypeKey, + Value: "MHJACCARD", + }, + }, cit1.newIndexParams) + assert.ElementsMatch(t, + []*commonpb.KeyValuePair{ + { + Key: DimKey, + Value: "128", + }, + }, cit1.newTypeParams) + }) + + t.Run("enable autoindex", func(t *testing.T) { + cit1 := createTestIndexTask() + paramtable.Init() + Params.Save(Params.AutoIndexConfig.Enable.Key, "true") + defer Params.Reset(Params.AutoIndexConfig.Enable.Key) + + err := cit1.parseIndexParams(context.TODO()) + assert.Error(t, err) + }) + + t.Run("disable autoindex", func(t *testing.T) { + cit1 := createTestIndexTask() + paramtable.Init() + Params.Save(Params.AutoIndexConfig.Enable.Key, "true") + Params.Save(Params.AutoIndexConfig.EnableDeduplicateIndex.Key, "true") + defer Params.Reset(Params.AutoIndexConfig.Enable.Key) + defer Params.Reset(Params.AutoIndexConfig.EnableDeduplicateIndex.Key) + + err := cit1.parseIndexParams(context.TODO()) + assert.NoError(t, err) + assert.ElementsMatch(t, + []*commonpb.KeyValuePair{ + { + Key: common.IndexTypeKey, + Value: "MINHASH_LSH", + }, + { + Key: MetricTypeKey, + Value: "MHJACCARD", + }, + }, cit1.newIndexParams) + assert.ElementsMatch(t, + []*commonpb.KeyValuePair{ + { + Key: DimKey, + Value: "128", + }, + }, cit1.newTypeParams) + }) +} + func Test_parseIndexParams(t *testing.T) { cit := &createIndexTask{ Condition: nil,