From 929dc658829076ec74fa50e7e4a0a7f9f7132d8e Mon Sep 17 00:00:00 2001 From: Spade A <71589810+SpadeA-Tang@users.noreply.github.com> Date: Thu, 13 Nov 2025 12:59:38 +0800 Subject: [PATCH] fix: fix index compatibility after upgrade (#45373) issue: https://github.com/milvus-io/milvus/issues/45380 --------- Signed-off-by: SpadeA --- internal/core/src/index/IndexFactory.cpp | 10 +++++++--- internal/core/unittest/test_sealed.cpp | 8 ++++---- .../test_utils/indexbuilder_test_utils.h | 19 +++++++++++-------- internal/proxy/task_index_test.go | 2 +- .../util/indexcgowrapper/codec_index_test.go | 13 +++---------- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/internal/core/src/index/IndexFactory.cpp b/internal/core/src/index/IndexFactory.cpp index 53790a9525..28e99788d0 100644 --- a/internal/core/src/index/IndexFactory.cpp +++ b/internal/core/src/index/IndexFactory.cpp @@ -86,12 +86,16 @@ IndexFactory::CreatePrimitiveScalarIndex( } if (index_type == BITMAP_INDEX_TYPE) { return std::make_unique>(file_manager_context); - } - if (index_type == HYBRID_INDEX_TYPE) { + } else if (index_type == HYBRID_INDEX_TYPE) { return std::make_unique>( create_index_info.tantivy_index_version, file_manager_context); + } else if (index_type == MARISA_TRIE || index_type == MARISA_TRIE_UPPER) { + return CreateStringIndexMarisa(file_manager_context); + } else if (index_type == ASCENDING_SORT) { + return CreateStringIndexSort(file_manager_context); + } else { + ThrowInfo(Unsupported, "unsupported index type: {}", index_type); } - return CreateStringIndexSort(file_manager_context); #else ThrowInfo(Unsupported, "unsupported platform"); #endif diff --git a/internal/core/unittest/test_sealed.cpp b/internal/core/unittest/test_sealed.cpp index 1b126f6a7f..f607093b16 100644 --- a/internal/core/unittest/test_sealed.cpp +++ b/internal/core/unittest/test_sealed.cpp @@ -883,7 +883,7 @@ TEST(Sealed, LoadPkScalarIndex) { LoadIndexInfo pk_index; pk_index.field_id = pk_id.get(); pk_index.field_type = DataType::INT64; - pk_index.index_params["index_type"] = "sort"; + pk_index.index_params["index_type"] = "STL_SORT"; auto pk_data = dataset.get_col(pk_id); auto index = GenScalarIndexing(N, pk_data.data()); pk_index.index_params = GenIndexParams(index.get()); @@ -962,7 +962,7 @@ TEST(Sealed, LoadScalarIndex) { LoadIndexInfo counter_index; counter_index.field_id = counter_id.get(); counter_index.field_type = DataType::INT64; - counter_index.index_params["index_type"] = "sort"; + counter_index.index_params["index_type"] = "STL_SORT"; auto counter_data = dataset.get_col(counter_id); auto index = GenScalarIndexing(N, counter_data.data()); counter_index.index_params = GenIndexParams(index.get()); @@ -972,7 +972,7 @@ TEST(Sealed, LoadScalarIndex) { LoadIndexInfo double_index; double_index.field_id = double_id.get(); double_index.field_type = DataType::DOUBLE; - double_index.index_params["index_type"] = "sort"; + double_index.index_params["index_type"] = "STL_SORT"; auto double_data = dataset.get_col(double_id); auto temp1 = GenScalarIndexing(N, double_data.data()); double_index.index_params = GenIndexParams(temp1.get()); @@ -982,7 +982,7 @@ TEST(Sealed, LoadScalarIndex) { LoadIndexInfo nothing_index; nothing_index.field_id = nothing_id.get(); nothing_index.field_type = DataType::INT32; - nothing_index.index_params["index_type"] = "sort"; + nothing_index.index_params["index_type"] = "STL_SORT"; auto nothing_data = dataset.get_col(nothing_id); auto temp2 = GenScalarIndexing(N, nothing_data.data()); nothing_index.index_params = GenIndexParams(temp2.get()); diff --git a/internal/core/unittest/test_utils/indexbuilder_test_utils.h b/internal/core/unittest/test_utils/indexbuilder_test_utils.h index 6e4ff41b06..5699c956aa 100644 --- a/internal/core/unittest/test_utils/indexbuilder_test_utils.h +++ b/internal/core/unittest/test_utils/indexbuilder_test_utils.h @@ -406,7 +406,8 @@ GenSortedArr(int64_t n) { std::vector GenBoolParams() { std::vector ret; - ret.emplace_back(ScalarTestParams(MapParams(), {{"index_type", "sort"}})); + ret.emplace_back( + ScalarTestParams(MapParams(), {{"index_type", "STL_SORT"}})); ret.emplace_back(ScalarTestParams(MapParams(), {{"index_type", "flat"}})); return ret; } @@ -414,7 +415,7 @@ GenBoolParams() { std::vector GenStringParams() { std::vector ret; - ret.emplace_back(ScalarTestParams(MapParams(), {{"index_type", "marisa"}})); + ret.emplace_back(ScalarTestParams(MapParams(), {{"index_type", "Trie"}})); return ret; } @@ -432,7 +433,8 @@ GenParams() { } std::vector ret; - ret.emplace_back(ScalarTestParams(MapParams(), {{"index_type", "sort"}})); + ret.emplace_back( + ScalarTestParams(MapParams(), {{"index_type", "STL_SORT"}})); ret.emplace_back(ScalarTestParams(MapParams(), {{"index_type", "flat"}})); return ret; } @@ -465,27 +467,28 @@ GenDsFromPB(const google::protobuf::Message& msg) { template inline std::vector GetIndexTypes() { - return std::vector{"sort", milvus::index::BITMAP_INDEX_TYPE}; + return std::vector{"STL_SORT", + milvus::index::BITMAP_INDEX_TYPE}; } template <> inline std::vector GetIndexTypes() { return std::vector{ - "sort", "marisa", milvus::index::BITMAP_INDEX_TYPE}; + "STL_SORT", "Trie", milvus::index::BITMAP_INDEX_TYPE}; } template inline std::vector GetIndexTypesV2() { - return std::vector{"sort", milvus::index::INVERTED_INDEX_TYPE}; + return std::vector{"STL_SORT", + milvus::index::INVERTED_INDEX_TYPE}; } template <> inline std::vector GetIndexTypesV2() { - return std::vector{"marisa", - milvus::index::INVERTED_INDEX_TYPE}; + return std::vector{"Trie", milvus::index::INVERTED_INDEX_TYPE}; } } // namespace diff --git a/internal/proxy/task_index_test.go b/internal/proxy/task_index_test.go index 2034c79e39..d03c262487 100644 --- a/internal/proxy/task_index_test.go +++ b/internal/proxy/task_index_test.go @@ -723,7 +723,7 @@ func Test_parseIndexParams(t *testing.T) { ExtraParams: []*commonpb.KeyValuePair{ { Key: common.IndexTypeKey, - Value: "marisa-trie", + Value: "Trie", }, }, IndexName: "", diff --git a/internal/util/indexcgowrapper/codec_index_test.go b/internal/util/indexcgowrapper/codec_index_test.go index aaecc98f58..ee8371c1d6 100644 --- a/internal/util/indexcgowrapper/codec_index_test.go +++ b/internal/util/indexcgowrapper/codec_index_test.go @@ -274,14 +274,7 @@ func genScalarIndexCases(dtype schemapb.DataType) []indexTestCase { dtype: dtype, typeParams: nil, indexParams: map[string]string{ - common.IndexTypeKey: "sort", - }, - }, - { - dtype: dtype, - typeParams: nil, - indexParams: map[string]string{ - common.IndexTypeKey: "flat", + common.IndexTypeKey: "STL_SORT", }, }, } @@ -293,14 +286,14 @@ func genStringIndexCases(dtype schemapb.DataType) []indexTestCase { dtype: dtype, typeParams: nil, indexParams: map[string]string{ - common.IndexTypeKey: "sort", + common.IndexTypeKey: "STL_SORT", }, }, { dtype: dtype, typeParams: nil, indexParams: map[string]string{ - common.IndexTypeKey: "marisa-trie", + common.IndexTypeKey: "Trie", }, }, }