diff --git a/internal/querynodev2/segments/mock_data.go b/internal/querynodev2/segments/mock_data.go index 1f734c6fccb35..79a4be0852111 100644 --- a/internal/querynodev2/segments/mock_data.go +++ b/internal/querynodev2/segments/mock_data.go @@ -813,6 +813,7 @@ func GenAndSaveIndexV2(collectionID, partitionID, segmentID, buildID int64, IndexName: indexInfo.GetIndexName(), IndexParams: indexInfo.GetIndexParams(), IndexFilePaths: indexPaths, + IndexID: indexInfo.GetIndexID(), CurrentIndexVersion: cCurrentIndexVersion, }, nil } diff --git a/internal/querynodev2/segments/segment.go b/internal/querynodev2/segments/segment.go index 9bc1a9e4b0353..83cf45acafece 100644 --- a/internal/querynodev2/segments/segment.go +++ b/internal/querynodev2/segments/segment.go @@ -363,7 +363,8 @@ func (s *LocalSegment) initializeSegment() error { indexedFieldInfos, fieldBinlogs := separateIndexAndBinlog(loadInfo) schemaHelper, _ := typeutil.CreateSchemaHelper(s.collection.Schema()) - for fieldID, info := range indexedFieldInfos { + for _, info := range indexedFieldInfos { + fieldID := info.IndexInfo.FieldID field, err := schemaHelper.GetFieldFromID(fieldID) if err != nil { return err diff --git a/internal/querynodev2/segments/segment_loader.go b/internal/querynodev2/segments/segment_loader.go index 296a5104bebc1..a43510e50507f 100644 --- a/internal/querynodev2/segments/segment_loader.go +++ b/internal/querynodev2/segments/segment_loader.go @@ -648,11 +648,11 @@ func (loader *segmentLoader) LoadBloomFilterSet(ctx context.Context, collectionI } func separateIndexAndBinlog(loadInfo *querypb.SegmentLoadInfo) (map[int64]*IndexedFieldInfo, []*datapb.FieldBinlog) { - fieldID2IndexInfo := make(map[int64]*querypb.FieldIndexInfo) + fieldID2IndexInfo := make(map[int64][]*querypb.FieldIndexInfo) for _, indexInfo := range loadInfo.IndexInfos { if len(indexInfo.GetIndexFilePaths()) > 0 { fieldID := indexInfo.FieldID - fieldID2IndexInfo[fieldID] = indexInfo + fieldID2IndexInfo[fieldID] = append(fieldID2IndexInfo[fieldID], indexInfo) } } @@ -663,11 +663,13 @@ func separateIndexAndBinlog(loadInfo *querypb.SegmentLoadInfo) (map[int64]*Index fieldID := fieldBinlog.FieldID // check num rows of data meta and index meta are consistent if indexInfo, ok := fieldID2IndexInfo[fieldID]; ok { - fieldInfo := &IndexedFieldInfo{ - FieldBinlog: fieldBinlog, - IndexInfo: indexInfo, + for _, index := range indexInfo { + fieldInfo := &IndexedFieldInfo{ + FieldBinlog: fieldBinlog, + IndexInfo: index, + } + indexedFieldInfos[index.IndexID] = fieldInfo } - indexedFieldInfos[fieldID] = fieldInfo } else { fieldBinlogs = append(fieldBinlogs, fieldBinlog) }