fix: fix index compatibility after upgrade (#45373)

issue: https://github.com/milvus-io/milvus/issues/45380

---------

Signed-off-by: SpadeA <tangchenjie1210@gmail.com>
This commit is contained in:
Spade A 2025-11-13 12:59:38 +08:00 committed by GitHub
parent 50f198e346
commit 929dc65882
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 26 additions and 26 deletions

View File

@ -86,12 +86,16 @@ IndexFactory::CreatePrimitiveScalarIndex<std::string>(
}
if (index_type == BITMAP_INDEX_TYPE) {
return std::make_unique<BitmapIndex<std::string>>(file_manager_context);
}
if (index_type == HYBRID_INDEX_TYPE) {
} else if (index_type == HYBRID_INDEX_TYPE) {
return std::make_unique<HybridScalarIndex<std::string>>(
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);
}
#else
ThrowInfo(Unsupported, "unsupported platform");
#endif

View File

@ -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<int64_t>(pk_id);
auto index = GenScalarIndexing<int64_t>(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<int64_t>(counter_id);
auto index = GenScalarIndexing<int64_t>(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>(double_id);
auto temp1 = GenScalarIndexing<double>(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<int32_t>(nothing_id);
auto temp2 = GenScalarIndexing<int32_t>(N, nothing_data.data());
nothing_index.index_params = GenIndexParams(temp2.get());

View File

@ -406,7 +406,8 @@ GenSortedArr<std::string>(int64_t n) {
std::vector<ScalarTestParams>
GenBoolParams() {
std::vector<ScalarTestParams> 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<ScalarTestParams>
GenStringParams() {
std::vector<ScalarTestParams> 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<ScalarTestParams> 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 <typename T>
inline std::vector<std::string>
GetIndexTypes() {
return std::vector<std::string>{"sort", milvus::index::BITMAP_INDEX_TYPE};
return std::vector<std::string>{"STL_SORT",
milvus::index::BITMAP_INDEX_TYPE};
}
template <>
inline std::vector<std::string>
GetIndexTypes<std::string>() {
return std::vector<std::string>{
"sort", "marisa", milvus::index::BITMAP_INDEX_TYPE};
"STL_SORT", "Trie", milvus::index::BITMAP_INDEX_TYPE};
}
template <typename T>
inline std::vector<std::string>
GetIndexTypesV2() {
return std::vector<std::string>{"sort", milvus::index::INVERTED_INDEX_TYPE};
return std::vector<std::string>{"STL_SORT",
milvus::index::INVERTED_INDEX_TYPE};
}
template <>
inline std::vector<std::string>
GetIndexTypesV2<std::string>() {
return std::vector<std::string>{"marisa",
milvus::index::INVERTED_INDEX_TYPE};
return std::vector<std::string>{"Trie", milvus::index::INVERTED_INDEX_TYPE};
}
} // namespace

View File

@ -723,7 +723,7 @@ func Test_parseIndexParams(t *testing.T) {
ExtraParams: []*commonpb.KeyValuePair{
{
Key: common.IndexTypeKey,
Value: "marisa-trie",
Value: "Trie",
},
},
IndexName: "",

View File

@ -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",
},
},
}