mirror of https://github.com/milvus-io/milvus.git
Fix error message for creating scalar index (#27382)
Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>pull/27394/head
parent
a3dd2756cf
commit
dedb90f85f
|
@ -630,6 +630,8 @@ func (s *Server) DropIndex(ctx context.Context, req *indexpb.DropIndexRequest) (
|
|||
for _, index := range indexes {
|
||||
indexIDs = append(indexIDs, index.IndexID)
|
||||
}
|
||||
// Compatibility logic. To prevent the index on the corresponding segments
|
||||
// from being dropped at the same time when dropping_partition in version 2.1
|
||||
if len(req.GetPartitionIDs()) == 0 {
|
||||
// drop collection index
|
||||
err := s.meta.MarkIndexAsDeleted(req.GetCollectionID(), indexIDs)
|
||||
|
|
|
@ -144,14 +144,15 @@ func (cit *createIndexTask) parseIndexParams() error {
|
|||
return merr.WrapErrParameterInvalid(DefaultStringIndexType, specifyIndexType, "index type not match")
|
||||
}
|
||||
indexParamsMap[common.IndexTypeKey] = DefaultStringIndexType
|
||||
} else {
|
||||
if cit.fieldSchema.DataType == schemapb.DataType_JSON {
|
||||
return merr.WrapErrParameterInvalid("not json field", "create index on json field", "create index on json field is not supported")
|
||||
}
|
||||
} else if typeutil.IsArithmetic(cit.fieldSchema.DataType) {
|
||||
if exist && specifyIndexType != DefaultIndexType {
|
||||
return merr.WrapErrParameterInvalid(DefaultStringIndexType, specifyIndexType, "index type not match")
|
||||
return merr.WrapErrParameterInvalid(DefaultIndexType, specifyIndexType, "index type not match")
|
||||
}
|
||||
indexParamsMap[common.IndexTypeKey] = DefaultIndexType
|
||||
} else {
|
||||
return merr.WrapErrParameterInvalid("supported field",
|
||||
fmt.Sprintf("create index on %s field", cit.fieldSchema.DataType.String()),
|
||||
"create index on json field is not supported")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -497,6 +497,42 @@ func Test_parseIndexParams(t *testing.T) {
|
|||
assert.Error(t, err)
|
||||
})
|
||||
|
||||
t.Run("create index on array field", func(t *testing.T) {
|
||||
cit3 := &createIndexTask{
|
||||
Condition: nil,
|
||||
req: &milvuspb.CreateIndexRequest{
|
||||
Base: nil,
|
||||
DbName: "",
|
||||
CollectionName: "",
|
||||
FieldName: "",
|
||||
ExtraParams: []*commonpb.KeyValuePair{
|
||||
{
|
||||
Key: common.IndexTypeKey,
|
||||
Value: "STL_SORT",
|
||||
},
|
||||
},
|
||||
IndexName: "",
|
||||
},
|
||||
ctx: nil,
|
||||
rootCoord: nil,
|
||||
result: nil,
|
||||
isAutoIndex: false,
|
||||
newIndexParams: nil,
|
||||
newTypeParams: nil,
|
||||
collectionID: 0,
|
||||
fieldSchema: &schemapb.FieldSchema{
|
||||
FieldID: 101,
|
||||
Name: "FieldID",
|
||||
IsPrimaryKey: false,
|
||||
Description: "field no.1",
|
||||
DataType: schemapb.DataType_Array,
|
||||
ElementType: schemapb.DataType_Int64,
|
||||
},
|
||||
}
|
||||
err := cit3.parseIndexParams()
|
||||
assert.Error(t, err)
|
||||
})
|
||||
|
||||
t.Run("pass vector index type on scalar field", func(t *testing.T) {
|
||||
cit4 := &createIndexTask{
|
||||
Condition: nil,
|
||||
|
|
Loading…
Reference in New Issue