fix:[2.5]remove the limit of deduplicate case when disable autoindex (#44782)

issue: https://github.com/milvus-io/milvus/issues/44702
related pr: https://github.com/milvus-io/milvus/pull/44825

Signed-off-by: cqy123456 <qianya.cheng@zilliz.com>
pull/44492/merge
cqy123456 2025-10-17 11:40:02 +08:00 committed by GitHub
parent 93411a388c
commit e4b72977dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 90 additions and 4 deletions

View File

@ -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

View File

@ -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,