enhance: Ignore index check for non-loaded vector field (#36170)

Related to #35996

For `Field Partial Load` feature, Milvus shall ignore index check for
non-loaded vector field.

Also, this PR unifies the logic of index check for load collection and
load partitions tasks.

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/36251/head^2
congqixia 2024-09-14 11:01:08 +08:00 committed by GitHub
parent 2d05b7f219
commit d07338b4b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 9 deletions

View File

@ -1548,7 +1548,6 @@ func (t *loadCollectionTask) Execute(ctx context.Context) (err error) {
return err
}
// prepare load field list
// TODO use load collection load field list after proto merged
loadFields, err := collSchema.GetLoadFieldIDs(t.GetLoadFields(), t.GetSkipLoadDynamicField())
if err != nil {
return err
@ -1575,9 +1574,10 @@ func (t *loadCollectionTask) Execute(ctx context.Context) (err error) {
fieldIndexIDs[index.FieldID] = index.IndexID
}
loadFieldsSet := typeutil.NewSet(loadFields...)
unindexedVecFields := make([]string, 0)
for _, field := range collSchema.GetFields() {
if typeutil.IsVectorType(field.GetDataType()) {
if typeutil.IsVectorType(field.GetDataType()) && loadFieldsSet.Contain(field.GetFieldID()) {
if _, ok := fieldIndexIDs[field.GetFieldID()]; !ok {
unindexedVecFields = append(unindexedVecFields, field.GetName())
}
@ -1819,21 +1819,28 @@ func (t *loadPartitionsTask) Execute(ctx context.Context) error {
return err
}
hasVecIndex := false
// not support multiple indexes on one field
fieldIndexIDs := make(map[int64]int64)
for _, index := range indexResponse.IndexInfos {
fieldIndexIDs[index.FieldID] = index.IndexID
for _, field := range collSchema.Fields {
if index.FieldID == field.FieldID && typeutil.IsVectorType(field.DataType) {
hasVecIndex = true
}
loadFieldsSet := typeutil.NewSet(loadFields...)
unindexedVecFields := make([]string, 0)
for _, field := range collSchema.GetFields() {
if typeutil.IsVectorType(field.GetDataType()) && loadFieldsSet.Contain(field.GetFieldID()) {
if _, ok := fieldIndexIDs[field.GetFieldID()]; !ok {
unindexedVecFields = append(unindexedVecFields, field.GetName())
}
}
}
if !hasVecIndex {
errMsg := fmt.Sprintf("there is no vector index on collection: %s, please create index firstly", t.LoadPartitionsRequest.CollectionName)
log.Ctx(ctx).Error(errMsg)
if len(unindexedVecFields) != 0 {
errMsg := fmt.Sprintf("there is no vector index on field: %v, please create index firstly", unindexedVecFields)
log.Debug(errMsg)
return errors.New(errMsg)
}
for _, partitionName := range t.PartitionNames {
partitionID, err := globalMetaCache.GetPartitionID(ctx, t.GetDbName(), t.CollectionName, partitionName)
if err != nil {