From 4b84ba2189bf8999ba9661989512ba56e189e457 Mon Sep 17 00:00:00 2001 From: cqy123456 <39671710+cqy123456@users.noreply.github.com> Date: Tue, 14 Oct 2025 16:14:00 +0800 Subject: [PATCH] fix:remove the limit of deduplicate case when disable autoindex (#44825) issue: https://github.com/milvus-io/milvus/issues/44702 Signed-off-by: cqy123456 --- internal/proxy/task_index.go | 4 -- internal/proxy/task_index_test.go | 90 +++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 4 deletions(-) diff --git a/internal/proxy/task_index.go b/internal/proxy/task_index.go index 426e65408e..7bb4a30e2c 100644 --- a/internal/proxy/task_index.go +++ b/internal/proxy/task_index.go @@ -351,10 +351,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 cc8abff4de..89e3c6afe6 100644 --- a/internal/proxy/task_index_test.go +++ b/internal/proxy/task_index_test.go @@ -310,6 +310,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,