mirror of https://github.com/milvus-io/milvus.git
Cherry-pick from master pr: #40254 Related to #40156 Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>pull/40359/head
parent
34f2bc0a68
commit
cc7d4ce399
|
@ -173,7 +173,12 @@ func (cit *createIndexTask) parseIndexParams(ctx context.Context) error {
|
|||
isVecIndex := typeutil.IsVectorType(cit.fieldSchema.DataType)
|
||||
indexParamsMap := make(map[string]string)
|
||||
|
||||
keys := typeutil.NewSet[string]()
|
||||
for _, kv := range cit.req.GetExtraParams() {
|
||||
if keys.Contain(kv.GetKey()) {
|
||||
return merr.WrapErrParameterInvalidMsg("duplicated index param (key=%s) (value=%s) found", kv.GetKey(), kv.GetValue())
|
||||
}
|
||||
keys.Insert(kv.GetKey())
|
||||
if kv.Key == common.IndexParamsKey {
|
||||
params, err := funcutil.JSONToMap(kv.Value)
|
||||
if err != nil {
|
||||
|
|
|
@ -1097,6 +1097,40 @@ func Test_parseIndexParams(t *testing.T) {
|
|||
// Out of range in json: param 'M' (3000) should be in range [2, 2048]
|
||||
assert.Error(t, err)
|
||||
})
|
||||
|
||||
t.Run("check_duplicated_extraparam", func(t *testing.T) {
|
||||
cit := &createIndexTask{
|
||||
Condition: nil,
|
||||
req: &milvuspb.CreateIndexRequest{
|
||||
ExtraParams: []*commonpb.KeyValuePair{
|
||||
{
|
||||
Key: common.IndexTypeKey,
|
||||
Value: "HNSW",
|
||||
},
|
||||
{
|
||||
Key: common.MetricTypeKey,
|
||||
Value: metric.L2,
|
||||
},
|
||||
{
|
||||
Key: common.MetricTypeKey,
|
||||
Value: metric.COSINE,
|
||||
},
|
||||
},
|
||||
IndexName: "",
|
||||
},
|
||||
fieldSchema: &schemapb.FieldSchema{
|
||||
FieldID: 101,
|
||||
Name: "FieldVector",
|
||||
IsPrimaryKey: false,
|
||||
DataType: schemapb.DataType_FloatVector,
|
||||
TypeParams: []*commonpb.KeyValuePair{
|
||||
{Key: common.DimKey, Value: "768"},
|
||||
},
|
||||
},
|
||||
}
|
||||
err := cit.parseIndexParams(context.TODO())
|
||||
assert.Error(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_wrapUserIndexParams(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue