diff --git a/internal/core/src/index/InvertedIndexTantivy.cpp b/internal/core/src/index/InvertedIndexTantivy.cpp index c1e99cf545..8f48b56845 100644 --- a/internal/core/src/index/InvertedIndexTantivy.cpp +++ b/internal/core/src/index/InvertedIndexTantivy.cpp @@ -255,7 +255,13 @@ InvertedIndexTantivy::LoadIndexMetas( if (file_name.find(INDEX_NULL_OFFSET_FILE_NAME) != std::string::npos) { null_offset_files.push_back(file); } + + // add slice meta file for null offset file compact + if (file_name == INDEX_FILE_SLICE_META) { + null_offset_files.push_back(file); + } } + if (null_offset_files.size() > 0) { // null offset file is sliced auto index_datas = mem_file_manager_->LoadIndexToMemory( @@ -283,6 +289,10 @@ InvertedIndexTantivy::RetainTantivyIndexFiles( auto file_name = boost::filesystem::path(file).filename().string(); return file_name == "index_type" || + // Slice meta is only used to compact null_offset files and non_exist_offset files. + // It can be removed after compaction is complete. + // Other index files are compacted by slice index instead of meta. + file_name == INDEX_FILE_SLICE_META || file_name.find(INDEX_NULL_OFFSET_FILE_NAME) != std::string::npos; }), diff --git a/internal/core/src/index/JsonInvertedIndex.cpp b/internal/core/src/index/JsonInvertedIndex.cpp index 5242e31be8..9044aace61 100644 --- a/internal/core/src/index/JsonInvertedIndex.cpp +++ b/internal/core/src/index/JsonInvertedIndex.cpp @@ -130,6 +130,10 @@ JsonInvertedIndex::LoadIndexMetas( std::string::npos) { non_exist_offset_files.push_back(file); } + // add slice meta file for null offset file compact + if (file_name == INDEX_FILE_SLICE_META) { + non_exist_offset_files.push_back(file); + } } if (non_exist_offset_files.size() > 0) { // null offset file is sliced