Append field indexID for index name (#20046)

Signed-off-by: cai.zhang <cai.zhang@zilliz.com>

Signed-off-by: cai.zhang <cai.zhang@zilliz.com>
This commit is contained in:
cai.zhang 2022-10-27 20:23:38 +08:00 committed by GitHub
parent 7cc182cb72
commit 4848edda8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 7 deletions

View File

@ -3,6 +3,7 @@ package meta
import ( import (
"fmt" "fmt"
"sort" "sort"
"strconv"
"strings" "strings"
"github.com/milvus-io/milvus-proto/go-api/commonpb" "github.com/milvus-io/milvus-proto/go-api/commonpb"
@ -172,12 +173,16 @@ func combineToCollectionIndexesMeta220(fieldIndexes FieldIndexes210, collectionI
for k, v := range newIndexParamsMap { for k, v := range newIndexParamsMap {
newIndexParams = append(newIndexParams, &commonpb.KeyValuePair{Key: k, Value: v}) newIndexParams = append(newIndexParams, &commonpb.KeyValuePair{Key: k, Value: v})
} }
newIndexName := indexInfo.GetIndexName()
if newIndexName == "_default_idx" {
newIndexName = "_default_idx_" + strconv.FormatInt(index.GetFiledID(), 10)
}
record := &model.Index{ record := &model.Index{
TenantID: "", // TODO: how to set this if we support mysql later? TenantID: "", // TODO: how to set this if we support mysql later?
CollectionID: collectionID, CollectionID: collectionID,
FieldID: index.GetFiledID(), FieldID: index.GetFiledID(),
IndexID: index.GetIndexID(), IndexID: index.GetIndexID(),
IndexName: indexInfo.GetIndexName(), IndexName: newIndexName,
IsDeleted: indexInfo.GetDeleted(), IsDeleted: indexInfo.GetDeleted(),
CreateTime: indexInfo.GetCreateTime(), CreateTime: indexInfo.GetCreateTime(),
TypeParams: field.GetTypeParams(), TypeParams: field.GetTypeParams(),

View File

@ -498,6 +498,9 @@ func (dit *dropIndexTask) PreExecute(ctx context.Context) error {
dit.Base.MsgType = commonpb.MsgType_DropIndex dit.Base.MsgType = commonpb.MsgType_DropIndex
dit.Base.SourceID = Params.ProxyCfg.GetNodeID() dit.Base.SourceID = Params.ProxyCfg.GetNodeID()
if dit.GetIndexName() == "" {
return errors.New("IndexName is not specified")
}
collName, fieldName := dit.CollectionName, dit.FieldName collName, fieldName := dit.CollectionName, dit.FieldName
if err := validateCollectionName(collName); err != nil { if err := validateCollectionName(collName); err != nil {
@ -508,10 +511,6 @@ func (dit *dropIndexTask) PreExecute(ctx context.Context) error {
return err return err
} }
if dit.IndexName == "" {
dit.IndexName = Params.CommonCfg.DefaultIndexName
}
collID, err := globalMetaCache.GetCollectionID(ctx, dit.CollectionName) collID, err := globalMetaCache.GetCollectionID(ctx, dit.CollectionName)
if err != nil { if err != nil {
return err return err

View File

@ -96,7 +96,7 @@ func TestDropIndexTask_PreExecute(t *testing.T) {
collectionName := "collection1" collectionName := "collection1"
collectionID := UniqueID(1) collectionID := UniqueID(1)
fieldName := "field1" fieldName := "field1"
indexName := "" indexName := "_default_idx_101"
Params.Init() Params.Init()
showCollectionMock := func(ctx context.Context, request *querypb.ShowCollectionsRequest) (*querypb.ShowCollectionsResponse, error) { showCollectionMock := func(ctx context.Context, request *querypb.ShowCollectionsRequest) (*querypb.ShowCollectionsResponse, error) {

View File

@ -12,7 +12,7 @@ allure-pytest==2.7.0
pytest-print==0.2.1 pytest-print==0.2.1
pytest-level==0.1.1 pytest-level==0.1.1
pytest-xdist==2.5.0 pytest-xdist==2.5.0
pymilvus==2.2.0.dev67 pymilvus==2.2.0.dev68
pytest-rerunfailures==9.1.1 pytest-rerunfailures==9.1.1
git+https://github.com/Projectplace/pytest-tags git+https://github.com/Projectplace/pytest-tags
ndg-httpsclient ndg-httpsclient