diff --git a/test/unit_test/CMakeLists.txt b/test/unit_test/CMakeLists.txt index a2e92827c..aaf7b0ca7 100644 --- a/test/unit_test/CMakeLists.txt +++ b/test/unit_test/CMakeLists.txt @@ -1,29 +1,39 @@ enable_testing() +add_subdirectory(legacy) add_subdirectory(sdk) -SET(UNIT_TEST_BIN "dingodb_unit_test") +if(WITH_DOC) + add_subdirectory(document) +endif() -file(GLOB TEST_SRCS "test_*.cc") +SET(UNIT_TEST_BIN "dingodb_unit_test") -add_executable(${UNIT_TEST_BIN} - main.cc - ${TEST_SRCS} - ) +add_executable(${UNIT_TEST_BIN} main.cc) add_dependencies(${UNIT_TEST_BIN} ${DEPEND_LIBS} sdk) -target_link_libraries(${UNIT_TEST_BIN} - $ - $ - ${DYNAMIC_LIB} - ${VECTOR_LIB} - sdk - $ - ${GTEST_LIBRARIES} - ${GMOCK_LIBRARIES} - "-Xlinker \"-(\"" - ${BLAS_LIBRARIES} - "-Xlinker \"-)\"" - ) +set(UNIT_TEST_LIBS + $ + $ + ${DYNAMIC_LIB} + ${VECTOR_LIB} + $ + sdk + $ +) + +if(WITH_DOC) + list(APPEND UNIT_TEST_LIBS $) +endif() + +set(UNIT_TEST_LIBS + ${UNIT_TEST_LIBS} + ${GTEST_LIBRARIES} + ${GMOCK_LIBRARIES} + "-Xlinker \"-(\"" + ${BLAS_LIBRARIES} + "-Xlinker \"-)\"" +) +target_link_libraries(${UNIT_TEST_BIN} ${UNIT_TEST_LIBS}) diff --git a/test/unit_test/document/CMakeLists.txt b/test/unit_test/document/CMakeLists.txt new file mode 100644 index 000000000..b78f682d7 --- /dev/null +++ b/test/unit_test/document/CMakeLists.txt @@ -0,0 +1,12 @@ +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/) + +set(DOCUMENT_UNIT_TEST_SRCS + test_tantivy_search.cc +) + +add_library(DOCUMENT_UNIT_TEST_OBJS + OBJECT + ${DOCUMENT_UNIT_TEST_SRCS} +) + +add_dependencies(DOCUMENT_UNIT_TEST_OBJS ${DEPEND_LIBS}) \ No newline at end of file diff --git a/test/unit_test/document/test_tantivy_search.cc b/test/unit_test/document/test_tantivy_search.cc new file mode 100644 index 000000000..ddb95c536 --- /dev/null +++ b/test/unit_test/document/test_tantivy_search.cc @@ -0,0 +1,634 @@ +// Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include + +#include + +#include "tantivy_search.h" + +static size_t log_level = 1; + +const std::string kTantivySearchTestIndexPath = "./tantivy_test_index"; +const std::string kTantivySearchTestLogPath = "./tantivy_test_log"; + +const std::string kStemJson = + R"({"col1": {"tokenizer": {"type": "stem", "stop_word_filters": ["english", "french"], "stem_languages": ["german", "english"], "length_limit": 60}}, "col2": {"tokenizer": {"type": "simple"}}})"; + +const std::string kRawJson = + R"({ "col1": { "tokenizer": { "type": "raw" } }, "col2": { "tokenizer": {"type": "raw"} }, "col3": { "tokenizer": {"type": "raw"} } })"; + +const std::string kSimpleJson = + R"lit({ "mapKeys(col1)": { "tokenizer": { "type": "stem", "stop_word_filters": ["english"], "stem_languages": ["english"]} }, "col2": { "tokenizer": {"type": "simple"} } })lit"; + +const std::string kSimpleJson2 = + R"({ "col1": { "tokenizer": { "type": "stem", "stop_word_filters": ["english"], "stem_languages": ["english"]} }, "col2": { "tokenizer": {"type": "simple"} } })"; + +const std::string kChineseJson = R"({"text":{"tokenizer":{"type":"chinese"}}})"; + +const std::string kMultiTypeColumnJson = + R"({"col1": { "tokenizer": { "type": "chinese"}}, "col2": { "tokenizer": {"type": "i64", "indexed": true }}, "col3": { "tokenizer": {"type": "f64", "indexed": true }}, "col4": { "tokenizer": {"type": "chinese"}} })"; + +class DingoTantivySearchTest : public testing::Test { + protected: + void SetUp() override { + // print test start info and current path + std::cout << "tantivy_search test start, current_path: " << std::filesystem::current_path() << '\n'; + } + void TearDown() override { + // remove kTantivySearchTestIndexPath and kTantivySearchTestLogPath + std::filesystem::remove_all(kTantivySearchTestIndexPath); + std::filesystem::remove_all(kTantivySearchTestLogPath); + + // print test end and current path + std::cout << "tantivy_search test end, current_path: " << std::filesystem::current_path() << '\n'; + } +}; + +TEST(DingoTantivySearchTest, test_default_create) { + std::filesystem::remove_all(kTantivySearchTestIndexPath); + tantivy_search_log4rs_initialize(kTantivySearchTestLogPath.c_str(), "info", true, false, false); + + std::string index_path{kTantivySearchTestIndexPath}; + std::vector column_names; + column_names.push_back("text"); + auto ret = ffi_create_index(index_path, column_names); + EXPECT_EQ(ret.result, true); + + ret = ffi_index_multi_column_docs(index_path, 0, {"text"}, + {"Ancient empires rise and fall, shaping history's course."}); + EXPECT_EQ(ret.result, true); + + ret = ffi_index_multi_column_docs(index_path, 1, {"text"}, + {"Artistic expressions reflect diverse cultural heritages."}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 2, {"text"}, + {"Social movements transform societies, forging new paths."}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 3, {"text"}, + {"Economies fluctuate, reflecting the complex " + "interplay of global forces."}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 4, {"text"}, + {"Strategic military campaigns alter the balance of power."}); + EXPECT_EQ(ret.result, true); + ret = + ffi_index_multi_column_docs(index_path, 5, {"text"}, {"Quantum leaps redefine understanding of physical laws."}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 6, {"text"}, {"Chemical reactions unlock mysteries of nature."}); + EXPECT_EQ(ret.result, true); + ret = + ffi_index_multi_column_docs(index_path, 7, {"text"}, {"Philosophical debates ponder the essence of existence."}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 8, {"text"}, {"Marriages blend traditions, celebrating love's union."}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 9, {"text"}, + {"Explorers discover uncharted territories, expanding world maps."}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 10, {"text"}, {"Innovations in technology drive societal progress."}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 11, {"text"}, + {"Environmental conservation efforts protect Earth's biodiversity."}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 12, {"text"}, + {"Diplomatic negotiations seek to resolve international conflicts."}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 13, {"text"}, + {"Ancient philosophies provide wisdom for modern dilemmas."}); + EXPECT_EQ(ret.result, true); + ret = + ffi_index_multi_column_docs(index_path, 14, {"text"}, {"Economic theories debate the merits of market systems."}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 15, {"text"}, + {"Military strategies evolve with technological advancements."}); + EXPECT_EQ(ret.result, true); + ret = + ffi_index_multi_column_docs(index_path, 16, {"text"}, {"Physics theories delve into the universe's mysteries."}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 17, {"text"}, + {"Chemical compounds play crucial roles in medical breakthroughs."}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 18, {"text"}, + {"Philosophers debate ethics in the age of artificial intelligence."}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 19, {"text"}, + {"Wedding ceremonies across cultures symbolize lifelong commitment."}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_writer_commit(index_path); + EXPECT_EQ(ret.result, true); + + ret = ffi_load_index_reader(index_path); + EXPECT_EQ(ret.result, true); + + auto result = ffi_bm25_search(index_path, "of", 10, {}, false).result; + + for (const auto& it : result) { + std::cout << "rowid:" << it.row_id << " score:" << it.score << " doc_id:" << it.doc_id << " seg_id:" << it.seg_id + << '\n'; + } + + ret = ffi_free_index_reader(index_path); + EXPECT_EQ(ret.result, true); + ret = ffi_free_index_writer(index_path); + EXPECT_EQ(ret.result, true); + + std::cout << __func__ << " done" << '\n'; +} + +TEST(DingoTantivySearchTest, test_get_index_info) { + std::filesystem::remove_all(kTantivySearchTestIndexPath); + tantivy_search_log4rs_initialize(kTantivySearchTestLogPath.c_str(), "info", true, false, false); + + std::string index_path{kTantivySearchTestIndexPath}; + std::vector column_names; + column_names.push_back("text"); + auto ret = ffi_create_index_with_parameter(index_path, column_names, kMultiTypeColumnJson); + EXPECT_EQ(ret.result, true); + ret = ffi_free_index_writer(index_path); + EXPECT_EQ(ret.result, true); + + auto index_meta = ffi_get_index_meta_json(index_path); + if (index_meta.error_code != 0) { + std::cout << "ffi_get_index_meta_json error:" << index_meta.error_msg.c_str() << '\n'; + } else { + std::cout << "ffi_get_index_meta_json success:" << index_meta.result.c_str() << '\n'; + } + + auto index_para = ffi_get_index_json_parameter(index_path); + if (index_para.error_code != 0) { + std::cout << "ffi_get_index_json_parameter error:" << index_para.error_msg.c_str() << '\n'; + } else { + std::cout << "ffi_get_index_json_parameter success:" << index_para.result.c_str() << '\n'; + } +} + +TEST(DingoTantivySearchTest, test_tokenizer_create) { + std::filesystem::remove_all(kTantivySearchTestIndexPath); + tantivy_search_log4rs_initialize(kTantivySearchTestLogPath.c_str(), "info", true, false, false); + + std::string index_path{kTantivySearchTestIndexPath}; + std::vector column_names; + column_names.push_back("text"); + auto ret = ffi_create_index_with_parameter(index_path, column_names, kChineseJson); + EXPECT_EQ(ret.result, true); + + ret = ffi_index_multi_column_docs(index_path, 0, {"text"}, + {"古代帝国的兴衰更迭,不仅塑造了历史的进程,也铭" + "刻了时代的变迁与文明的发展。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 1, {"text"}, + {"艺术的多样表达方式反映了不同文化的丰富遗产,展" + "现了人类创造力的无限可能。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 2, {"text"}, + {"社会运动如同时代的浪潮,改变着社会的面貌,为历史开辟新的道路和方向。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 3, {"text"}, + {"全球经济的波动复杂多变,如同镜子反映出世界各国" + "之间错综复杂的力量关系。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 4, {"text"}, + {"战略性的军事行动改变了世界的权力格局,也重新定义了国际政治的均势。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 5, {"text"}, + {"量子物理的飞跃性进展,彻底改写了我们对物理世界规律的理解和认知。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 6, {"text"}, + {"化学反应不仅揭开了大自然奥秘的一角,也为科学的探索提供了新的窗口。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 7, {"text"}, + {"哲学家的辩论深入探讨了生命存在的本质,引发人们对生存意义的深刻思考。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 8, {"text"}, + {"婚姻的融合不仅是情感的结合,更是不同传统和文化" + "的交汇,彰显了爱的力量。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 9, {"text"}, + {"勇敢的探险家发现了未知的领域,为人类的世界观增添了新的地理篇章。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 10, {"text"}, + {"科技创新的步伐从未停歇,它推动着社会的进步,引领着时代的前行。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 11, {"text"}, + {"环保行动积极努力保护地球的生物多样性,为我们共" + "同的家园筑起绿色的屏障。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 12, {"text"}, + {"外交谈判在国际舞台上寻求和平解决冲突,致力于构建一个更加和谐的世界。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 13, {"text"}, + {"古代哲学的智慧至今仍对现代社会的诸多难题提供启示和解答,影响深远。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 14, {"text"}, + {"经济学理论围绕市场体系的优劣进行了深入的探讨与" + "辩论,对经济发展有重要指导意义。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 15, {"text"}, + {"随着科技的不断进步,军事战略也在不断演变,应对新时代的挑战和需求。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 16, {"text"}, + {"现代物理学理论深入挖掘宇宙的奥秘,试图解开那些探索宇宙时的未知之谜。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 17, {"text"}, + {"在医学领域,化学化合物的作用至关重要,它们在许" + "多重大医疗突破中扮演了核心角色。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 18, {"text"}, + {"当代哲学家在探讨人工智能时代的伦理道德问题,对" + "机器与人类的关系进行深刻反思。"}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_column_docs(index_path, 19, {"text"}, + {"不同文化背景下的婚礼仪式代表着一生的承诺与责任" + ",象征着两颗心的永恒结合。"}); + EXPECT_EQ(ret.result, true); + + ret = ffi_index_writer_commit(index_path); + EXPECT_EQ(ret.result, true); + + ret = ffi_load_index_reader(index_path); + EXPECT_EQ(ret.result, true); + + auto result = ffi_bm25_search(index_path, "影响深远", 10, {}, false).result; + + for (const auto& it : result) { + std::cout << "rowid:" << it.row_id << " score:" << it.score << " doc_id:" << it.doc_id << " seg_id:" << it.seg_id + << '\n'; + } + + ret = ffi_free_index_reader(index_path); + EXPECT_EQ(ret.result, true); + ret = ffi_free_index_writer(index_path); + EXPECT_EQ(ret.result, true); + + std::cout << __func__ << " done" << '\n'; +} + +void CreateAndLoadChineseData(const std::string& index_path) { + std::filesystem::remove_all(index_path); + tantivy_search_log4rs_initialize(kTantivySearchTestLogPath.c_str(), "info", true, false, false); + + std::vector column_names; + column_names.push_back("col1"); + column_names.push_back("col2"); + column_names.push_back("col3"); + column_names.push_back("col4"); + + std::vector text_column_names; + text_column_names.push_back("col1"); + text_column_names.push_back("col4"); + + std::vector i64_column_names; + i64_column_names.push_back("col2"); + + std::vector f64_column_names; + f64_column_names.push_back("col3"); + + auto ret = ffi_create_index_with_parameter(index_path, column_names, kMultiTypeColumnJson); + EXPECT_EQ(ret.result, true); + + ret = ffi_index_multi_type_column_docs(index_path, 0, {"col1", "col4"}, + {"古代帝国的兴衰更迭,不仅塑造了历史的进程,也铭" + "刻了时代的变迁与文明的发展。", + "Ancient empires rise and fall, shaping history's course."}, + {"col2"}, {100}, {"col3"}, {100.0}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_type_column_docs(index_path, 1, text_column_names, + {"艺术的多样表达方式反映了不同文化的丰富遗产,展现了人类创造力的无限可能" + "。", + "Artistic expressions reflect diverse cultural heritages."}, + i64_column_names, {200}, f64_column_names, {200.0}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_type_column_docs(index_path, 2, text_column_names, + {"社会运动如同时代的浪潮,改变着社会的面貌,为历史开辟新的道路和方向。", + "Social movements transform societies, forging new paths."}, + i64_column_names, {300}, f64_column_names, {300.0}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_type_column_docs(index_path, 3, text_column_names, + {"全球经济的波动复杂多变,如同镜子反映出世界各国之间错综复杂的力量关系。", + "Global economic fluctuations are complex and volatile, reflecting " + "intricate power dynamics among nations."}, + i64_column_names, {400}, f64_column_names, {400.0}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_type_column_docs(index_path, 4, text_column_names, + {"战略性的军事行动改变了世界的权力格局,也重新定义了国际政治的均势。", + "Strategic military campaigns alter the balance of power."}, + i64_column_names, {500}, f64_column_names, {500.0}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_type_column_docs(index_path, 5, text_column_names, + {"量子物理的飞跃性进展,彻底改写了我们对物理世界规律的理解和认知。", + "Quantum leaps redefine understanding of physical laws."}, + i64_column_names, {600}, f64_column_names, {600.0}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_type_column_docs(index_path, 6, text_column_names, + {"化学反应不仅揭开了大自然奥秘的一角,也为科学的探索提供了新的窗口。", + "Chemical reactions unlock mysteries of nature."}, + i64_column_names, {700}, f64_column_names, {700.0}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_type_column_docs(index_path, 7, text_column_names, + {"哲学家的辩论深入探讨了生命存在的本质,引发人们对生存意义的深刻思考。", + "Philosophical debates ponder the essence of existence."}, + i64_column_names, {800}, f64_column_names, {800.0}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_type_column_docs( + index_path, 8, text_column_names, + {"婚姻的融合不仅是情感的结合,更是不同传统和文化的交汇,彰显了爱的力量,是社会发展的必须。", + "Marriages blend traditions, celebrating love's union."}, + i64_column_names, {900}, f64_column_names, {900.0}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_type_column_docs(index_path, 9, text_column_names, + {"勇敢的探险家发现了未知的领域,为人类的世界观增添了新的地理篇章。", + "Brave explorers discover uncharted territories, expanding world maps."}, + i64_column_names, {1000}, f64_column_names, {1000.0}); + EXPECT_EQ(ret.result, true); + + ret = ffi_index_writer_commit(index_path); + EXPECT_EQ(ret.result, true); + ret = ffi_free_index_writer(index_path); + EXPECT_EQ(ret.result, true); +} + +TEST(DingoTantivySearchTest, test_multi_type_column) { + std::filesystem::remove_all(kTantivySearchTestIndexPath); + tantivy_search_log4rs_initialize(kTantivySearchTestLogPath.c_str(), "info", true, false, false); + + std::string index_path{kTantivySearchTestIndexPath}; + std::vector column_names; + column_names.push_back("col1"); + column_names.push_back("col2"); + column_names.push_back("col3"); + column_names.push_back("col4"); + + std::vector text_column_names; + text_column_names.push_back("col1"); + text_column_names.push_back("col4"); + + std::vector i64_column_names; + i64_column_names.push_back("col2"); + + std::vector f64_column_names; + f64_column_names.push_back("col3"); + + auto ret = ffi_create_index_with_parameter(index_path, column_names, kMultiTypeColumnJson); + EXPECT_EQ(ret.result, true); + + ret = ffi_index_multi_type_column_docs(index_path, 0, {"col1", "col4"}, + {"古代帝国的兴衰更迭,不仅塑造了历史的进程,也铭" + "刻了时代的变迁与文明的发展。", + "Ancient empires rise and fall, shaping history's course."}, + {"col2"}, {100}, {"col3"}, {100.0}); + std::cout << "ffi_index_multi_type_column_docs ret:" << ret.result << '\n'; + EXPECT_EQ(ret.result, true); + ret = + + ffi_index_multi_type_column_docs(index_path, 1, text_column_names, + {"艺术的多样表达方式反映了不同文化的丰富遗产,展现了人类创造力的无限可能" + "。", + "Artistic expressions reflect diverse cultural heritages."}, + i64_column_names, {200}, f64_column_names, {200.0}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_type_column_docs(index_path, 2, text_column_names, + {"社会运动如同时代的浪潮,改变着社会的面貌,为历史开辟新的道路和方向。", + "Social movements transform societies, forging new paths."}, + i64_column_names, {300}, f64_column_names, {300.0}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_type_column_docs(index_path, 3, text_column_names, + {"全球经济的波动复杂多变,如同镜子反映出世界各国之间错综复杂的力量关系。", + "Global economic fluctuations are complex and volatile, reflecting " + "intricate power dynamics among nations."}, + i64_column_names, {400}, f64_column_names, {400.0}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_type_column_docs(index_path, 4, text_column_names, + {"战略性的军事行动改变了世界的权力格局,也重新定义了国际政治的均势。", + "Strategic military campaigns alter the balance of power."}, + i64_column_names, {500}, f64_column_names, {500.0}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_type_column_docs(index_path, 5, text_column_names, + {"量子物理的飞跃性进展,彻底改写了我们对物理世界规律的理解和认知。", + "Quantum leaps redefine understanding of physical laws."}, + i64_column_names, {600}, f64_column_names, {600.0}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_type_column_docs(index_path, 6, text_column_names, + {"化学反应不仅揭开了大自然奥秘的一角,也为科学的探索提供了新的窗口。", + "Chemical reactions unlock mysteries of nature."}, + i64_column_names, {700}, f64_column_names, {700.0}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_type_column_docs(index_path, 7, text_column_names, + {"哲学家的辩论深入探讨了生命存在的本质,引发人们对生存意义的深刻思考。", + "Philosophical debates ponder the essence of existence."}, + i64_column_names, {800}, f64_column_names, {800.0}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_type_column_docs( + index_path, 8, text_column_names, + {"婚姻的融合不仅是情感的结合,更是不同传统和文化的交汇,彰显了爱的力量,是社会发展的必须。", + "Marriages blend traditions, celebrating love's union."}, + i64_column_names, {900}, f64_column_names, {900.0}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_multi_type_column_docs(index_path, 9, text_column_names, + {"勇敢的探险家发现了未知的领域,为人类的世界观增添了新的地理篇章。", + "Brave explorers discover uncharted territories, expanding world maps."}, + i64_column_names, {1000}, f64_column_names, {1000.0}); + EXPECT_EQ(ret.result, true); + ret = ffi_index_writer_commit(index_path); + EXPECT_EQ(ret.result, true); + + ret = ffi_load_index_reader(index_path); + EXPECT_EQ(ret.result, true); + + auto result = ffi_bm25_search(index_path, "社会", 10, {}, false).result; + std::cout << "ffi_bm25_search result size:" << result.size() << '\n'; + + for (const auto& it : result) { + std::cout << "ffi_bm25_search rowid:" << it.row_id << " score:" << it.score << " doc_id:" << it.doc_id + << " seg_id:" << it.seg_id << '\n'; + } + + result = ffi_bm25_search_with_column_names(index_path, "社会", 10, {}, false, {"col1"}).result; + std::cout << "ffi_bm25_search_with_column_names col1 result size:" << result.size() << '\n'; + for (const auto& it : result) { + std::cout << "ffi_bm25_search_with_column_names rowid:" << it.row_id << " score:" << it.score + << " doc_id:" << it.doc_id << " seg_id:" << it.seg_id << '\n'; + } + + result = ffi_bm25_search_with_column_names(index_path, "balance", 10, {}, false, {"col4"}).result; + std::cout << "ffi_bm25_search_with_column_names col4 result size:" << result.size() << '\n'; + for (const auto& it : result) { + std::cout << "ffi_bm25_search_with_column_names rowid:" << it.row_id << " score:" << it.score + << " doc_id:" << it.doc_id << " seg_id:" << it.seg_id << '\n'; + } + + result = ffi_bm25_search_with_column_names(index_path, "社会", 10, {}, false, {"col1", "col4"}).result; + std::cout << "ffi_bm25_search_with_column_names col1,col4 result size:" << result.size() << '\n'; + for (const auto& it : result) { + std::cout << "ffi_bm25_search_with_column_names rowid:" << it.row_id << " score:" << it.score + << " doc_id:" << it.doc_id << " seg_id:" << it.seg_id << '\n'; + } + + result = ffi_bm25_search_with_column_names(index_path, "社会", 10, {}, false, {"col11", "col44"}).result; + std::cout << "ffi_bm25_search_with_column_names col11,col44 result size:" << result.size() << '\n'; + + result = ffi_bm25_search_with_column_names(index_path, "col2: IN [200 300 400]", 10, {}, false, {}).result; + std::cout << "ffi_bm25_search_with_column_names-1 parser result size:" << result.size() << '\n'; + for (const auto& it : result) { + std::cout << "ffi_bm25_search_with_column_names rowid:" << it.row_id << " score:" << it.score + << " doc_id:" << it.doc_id << " seg_id:" << it.seg_id << '\n'; + } + + result = ffi_bm25_search_with_column_names(index_path, "col222: IN [200 300 400]", 10, {}, false, {}).result; + std::cout << "ffi_bm25_search_with_column_names-2 parser result size:" << result.size() << '\n'; + for (const auto& it : result) { + std::cout << "ffi_bm25_search_with_column_names rowid:" << it.row_id << " score:" << it.score + << " doc_id:" << it.doc_id << " seg_id:" << it.seg_id << '\n'; + } + + auto bm25_result = ffi_bm25_search_with_column_names(index_path, "col2: IN [200 300 400]", 10, {}, false, {}); + if (bm25_result.error_code != 0) { + std::cout << "ffi_bm25_search_with_column_names2-1 error:" << bm25_result.error_msg.c_str() << '\n'; + } else { + std::cout << "ffi_bm25_search_with_column_names2-1 parser result size:" << bm25_result.result.size() << '\n'; + for (const auto& it : bm25_result.result) { + std::cout << "ffi_bm25_search_with_column_names2 rowid:" << it.row_id << " score:" << it.score + << " doc_id:" << it.doc_id << " seg_id:" << it.seg_id << '\n'; + } + } + + bm25_result = + ffi_bm25_search_with_column_names(index_path, "col222: IN [200 300 400 500 600 700 800]", 10, {}, false, {}); + if (bm25_result.error_code != 0) { + std::cout << "ffi_bm25_search_with_column_names2-2 error:" << bm25_result.error_msg.c_str() << '\n'; + } else { + std::cout << "ffi_bm25_search_with_column_names2-2 parser result size:" << bm25_result.result.size() << '\n'; + for (const auto& it : bm25_result.result) { + std::cout << "ffi_bm25_search_with_column_names2 rowid:" << it.row_id << " score:" << it.score + << " doc_id:" << it.doc_id << " seg_id:" << it.seg_id << '\n'; + } + } + + auto reload_result = ffi_index_reader_reload(index_path); + if (reload_result.error_code != 0) { + std::cout << "ffi_index_reader_reload error:" << reload_result.error_msg.c_str() << '\n'; + } else { + std::cout << "ffi_index_reader_reload success" << '\n'; + } + + std::vector alived_ids; + alived_ids.push_back(2); + alived_ids.push_back(4); + alived_ids.push_back(5); + alived_ids.push_back(6); + alived_ids.push_back(7); + bm25_result = + ffi_bm25_search_with_column_names(index_path, "col2: IN [800 700 600 500 400 300 200]", 3, alived_ids, true, {}); + if (bm25_result.error_code != 0) { + std::cout << "ffi_bm25_search_with_column_names2-3 filter_ids error:" << bm25_result.error_msg.c_str() << '\n'; + } else { + std::cout << "ffi_bm25_search_with_column_names2-3 filter_ids parser result size:" << bm25_result.result.size() + << '\n'; + for (const auto& it : bm25_result.result) { + std::cout << "ffi_bm25_search_with_column_names2 rowid:" << it.row_id << " score:" << it.score + << " doc_id:" << it.doc_id << " seg_id:" << it.seg_id << '\n'; + } + } + + ret = ffi_free_index_reader(index_path); + EXPECT_EQ(ret.result, true); + ret = ffi_free_index_writer(index_path); + EXPECT_EQ(ret.result, true); + + std::cout << __func__ << " done" << '\n'; +} + +TEST(DingoTantivySearchTest, test_load_multi_type_column) { + std::string index_path{kTantivySearchTestIndexPath}; + CreateAndLoadChineseData(index_path); + + tantivy_search_log4rs_initialize(kTantivySearchTestLogPath.c_str(), "info", true, false, false); + + BoolResult bool_result; + bool_result = ffi_load_index_reader(index_path); + if (!bool_result.result) { + std::cout << "ffi_load_index_reader error:" << bool_result.error_msg.c_str() << '\n'; + EXPECT_EQ(bool_result.result, true); + return; + } else { + std::cout << "ffi_load_index_reader success" << '\n'; + } + + bool_result = ffi_load_index_writer(index_path); + if (!bool_result.result) { + std::cout << "ffi_load_index_writer error:" << bool_result.error_msg.c_str() << '\n'; + EXPECT_EQ(bool_result.result, true); + return; + } else { + std::cout << "ffi_load_index_writer success" << '\n'; + } + + bool_result = ffi_index_multi_type_column_docs(index_path, 0, {"col1", "col4"}, + {"古代帝国的兴衰更迭,不仅塑造了历史的进程,也铭" + "刻了时代的变迁与文明的发展。", + "Ancient empires rise and fall, shaping history's course."}, + {"col2"}, {101}, {}, {}); + if (!bool_result.result) { + std::cout << "ffi_index_multi_type_column_docs error:" << bool_result.error_msg.c_str() << '\n'; + EXPECT_EQ(bool_result.result, true); + } else { + std::cout << "ffi_index_multi_type_column_docs ret:" << bool_result.result << '\n'; + } + + bool_result = ffi_index_writer_commit(index_path); + if (!bool_result.result) { + std::cout << "ffi_index_writer_commit error:" << bool_result.error_msg.c_str() << '\n'; + EXPECT_EQ(bool_result.result, true); + } else { + std::cout << "ffi_index_writer_commit success" << '\n'; + } + + bool_result = ffi_index_reader_reload(index_path); + if (!bool_result.result) { + std::cout << "ffi_index_reader_reload error:" << bool_result.error_msg.c_str() << '\n'; + EXPECT_EQ(bool_result.result, true); + } else { + std::cout << "ffi_index_reader_reload success" << '\n'; + } + + auto bm25_result = ffi_bm25_search_with_column_names(index_path, "col2: IN [101]", 10, {}, false, {}); + if (bm25_result.error_code != 0) { + std::cout << "ffi_bm25_search_with_column_names2-1 error:" << bm25_result.error_msg.c_str() << '\n'; + EXPECT_EQ(bm25_result.error_code, 0); + } else { + std::cout << "ffi_bm25_search_with_column_names2-1 parser result size:" << bm25_result.result.size() << '\n'; + for (const auto& it : bm25_result.result) { + std::cout << "ffi_bm25_search_with_column_names2 rowid:" << it.row_id << " score:" << it.score + << " doc_id:" << it.doc_id << " seg_id:" << it.seg_id << '\n'; + } + } + + bool_result = ffi_free_index_reader(index_path); + if (!bool_result.result) { + std::cout << "ffi_free_index_reader error:" << bool_result.error_msg.c_str() << '\n'; + EXPECT_EQ(bool_result.result, true); + } else { + std::cout << "ffi_free_index_reader success" << '\n'; + } + + bool_result = ffi_free_index_writer(index_path); + if (!bool_result.result) { + std::cout << "ffi_free_index_writer error:" << bool_result.error_msg.c_str() << '\n'; + EXPECT_EQ(bool_result.result, true); + } else { + std::cout << "ffi_free_index_writer success" << '\n'; + } + + std::cout << __func__ << " done" << '\n'; +} diff --git a/test/unit_test/legacy/CMakeLists.txt b/test/unit_test/legacy/CMakeLists.txt new file mode 100644 index 000000000..64f1854e8 --- /dev/null +++ b/test/unit_test/legacy/CMakeLists.txt @@ -0,0 +1,16 @@ +# include_directories(${CMAKE_CURRENT_SOURCE_DIR}/) + +file(GLOB LEGACY_UNIT_TEST_COMMON_SRCS "common/*.cc") +file(GLOB LEGACY_UNIT_TEST_VECTOR_SRCS "vector/*.cc") + +set(LEGACY_UNIT_TEST_SRCS + ${LEGACY_UNIT_TEST_COMMON_SRCS} + ${LEGACY_UNIT_TEST_VECTOR_SRCS} +) + +add_library(LEGACY_UNIT_TEST_OBJS + OBJECT + ${LEGACY_UNIT_TEST_SRCS} +) + +add_dependencies(LEGACY_UNIT_TEST_OBJS ${DEPEND_LIBS}) \ No newline at end of file diff --git a/test/unit_test/test_bdb_engine.cc b/test/unit_test/legacy/common/test_bdb_engine.cc similarity index 100% rename from test/unit_test/test_bdb_engine.cc rename to test/unit_test/legacy/common/test_bdb_engine.cc diff --git a/test/unit_test/test_codec.cc b/test/unit_test/legacy/common/test_codec.cc similarity index 100% rename from test/unit_test/test_codec.cc rename to test/unit_test/legacy/common/test_codec.cc diff --git a/test/unit_test/test_coordinator.cc b/test/unit_test/legacy/common/test_coordinator.cc similarity index 100% rename from test/unit_test/test_coordinator.cc rename to test/unit_test/legacy/common/test_coordinator.cc diff --git a/test/unit_test/test_coordinator_meta_storage.cc b/test/unit_test/legacy/common/test_coordinator_meta_storage.cc similarity index 100% rename from test/unit_test/test_coordinator_meta_storage.cc rename to test/unit_test/legacy/common/test_coordinator_meta_storage.cc diff --git a/test/unit_test/test_coprocessor.cc b/test/unit_test/legacy/common/test_coprocessor.cc similarity index 100% rename from test/unit_test/test_coprocessor.cc rename to test/unit_test/legacy/common/test_coprocessor.cc diff --git a/test/unit_test/test_coprocessor_aggregation_manager.cc b/test/unit_test/legacy/common/test_coprocessor_aggregation_manager.cc similarity index 100% rename from test/unit_test/test_coprocessor_aggregation_manager.cc rename to test/unit_test/legacy/common/test_coprocessor_aggregation_manager.cc diff --git a/test/unit_test/test_coprocessor_utils.cc b/test/unit_test/legacy/common/test_coprocessor_utils.cc similarity index 100% rename from test/unit_test/test_coprocessor_utils.cc rename to test/unit_test/legacy/common/test_coprocessor_utils.cc diff --git a/test/unit_test/test_coprocessor_v2.cc b/test/unit_test/legacy/common/test_coprocessor_v2.cc similarity index 100% rename from test/unit_test/test_coprocessor_v2.cc rename to test/unit_test/legacy/common/test_coprocessor_v2.cc diff --git a/test/unit_test/test_crontab.cc b/test/unit_test/legacy/common/test_crontab.cc similarity index 100% rename from test/unit_test/test_crontab.cc rename to test/unit_test/legacy/common/test_crontab.cc diff --git a/test/unit_test/test_failpoint.cc b/test/unit_test/legacy/common/test_failpoint.cc similarity index 100% rename from test/unit_test/test_failpoint.cc rename to test/unit_test/legacy/common/test_failpoint.cc diff --git a/test/unit_test/test_google_sanitize.cc b/test/unit_test/legacy/common/test_google_sanitize.cc similarity index 100% rename from test/unit_test/test_google_sanitize.cc rename to test/unit_test/legacy/common/test_google_sanitize.cc diff --git a/test/unit_test/test_helper.cc b/test/unit_test/legacy/common/test_helper.cc similarity index 100% rename from test/unit_test/test_helper.cc rename to test/unit_test/legacy/common/test_helper.cc diff --git a/test/unit_test/test_latch.cc b/test/unit_test/legacy/common/test_latch.cc similarity index 100% rename from test/unit_test/test_latch.cc rename to test/unit_test/legacy/common/test_latch.cc diff --git a/test/unit_test/test_log.cc b/test/unit_test/legacy/common/test_log.cc similarity index 100% rename from test/unit_test/test_log.cc rename to test/unit_test/legacy/common/test_log.cc diff --git a/test/unit_test/test_pb.cc b/test/unit_test/legacy/common/test_pb.cc similarity index 100% rename from test/unit_test/test_pb.cc rename to test/unit_test/legacy/common/test_pb.cc diff --git a/test/unit_test/test_raft_node.cc b/test/unit_test/legacy/common/test_raft_node.cc similarity index 100% rename from test/unit_test/test_raft_node.cc rename to test/unit_test/legacy/common/test_raft_node.cc diff --git a/test/unit_test/test_raft_snapshot_handler.cc b/test/unit_test/legacy/common/test_raft_snapshot_handler.cc similarity index 100% rename from test/unit_test/test_raft_snapshot_handler.cc rename to test/unit_test/legacy/common/test_raft_snapshot_handler.cc diff --git a/test/unit_test/test_region_controller.cc b/test/unit_test/legacy/common/test_region_controller.cc similarity index 100% rename from test/unit_test/test_region_controller.cc rename to test/unit_test/legacy/common/test_region_controller.cc diff --git a/test/unit_test/test_rel_expr_helper.cc b/test/unit_test/legacy/common/test_rel_expr_helper.cc similarity index 100% rename from test/unit_test/test_rel_expr_helper.cc rename to test/unit_test/legacy/common/test_rel_expr_helper.cc diff --git a/test/unit_test/test_rocks_engine.cc b/test/unit_test/legacy/common/test_rocks_engine.cc similarity index 100% rename from test/unit_test/test_rocks_engine.cc rename to test/unit_test/legacy/common/test_rocks_engine.cc diff --git a/test/unit_test/test_rocks_engine_destroy.cc b/test/unit_test/legacy/common/test_rocks_engine_destroy.cc similarity index 100% rename from test/unit_test/test_rocks_engine_destroy.cc rename to test/unit_test/legacy/common/test_rocks_engine_destroy.cc diff --git a/test/unit_test/test_runnable.cc b/test/unit_test/legacy/common/test_runnable.cc similarity index 100% rename from test/unit_test/test_runnable.cc rename to test/unit_test/legacy/common/test_runnable.cc diff --git a/test/unit_test/test_safe_map.cc b/test/unit_test/legacy/common/test_safe_map.cc similarity index 100% rename from test/unit_test/test_safe_map.cc rename to test/unit_test/legacy/common/test_safe_map.cc diff --git a/test/unit_test/test_scan.cc b/test/unit_test/legacy/common/test_scan.cc similarity index 100% rename from test/unit_test/test_scan.cc rename to test/unit_test/legacy/common/test_scan.cc diff --git a/test/unit_test/test_scan_v2.cc b/test/unit_test/legacy/common/test_scan_v2.cc similarity index 100% rename from test/unit_test/test_scan_v2.cc rename to test/unit_test/legacy/common/test_scan_v2.cc diff --git a/test/unit_test/test_scan_with_coprocessor.cc b/test/unit_test/legacy/common/test_scan_with_coprocessor.cc similarity index 100% rename from test/unit_test/test_scan_with_coprocessor.cc rename to test/unit_test/legacy/common/test_scan_with_coprocessor.cc diff --git a/test/unit_test/test_scan_with_coprocessor_v2.cc b/test/unit_test/legacy/common/test_scan_with_coprocessor_v2.cc similarity index 100% rename from test/unit_test/test_scan_with_coprocessor_v2.cc rename to test/unit_test/legacy/common/test_scan_with_coprocessor_v2.cc diff --git a/test/unit_test/test_segment_log_storage.cc b/test/unit_test/legacy/common/test_segment_log_storage.cc similarity index 100% rename from test/unit_test/test_segment_log_storage.cc rename to test/unit_test/legacy/common/test_segment_log_storage.cc diff --git a/test/unit_test/test_serial.cc b/test/unit_test/legacy/common/test_serial.cc similarity index 100% rename from test/unit_test/test_serial.cc rename to test/unit_test/legacy/common/test_serial.cc diff --git a/test/unit_test/test_serial_list_type.cc b/test/unit_test/legacy/common/test_serial_list_type.cc similarity index 100% rename from test/unit_test/test_serial_list_type.cc rename to test/unit_test/legacy/common/test_serial_list_type.cc diff --git a/test/unit_test/test_serial_selection.cc b/test/unit_test/legacy/common/test_serial_selection.cc similarity index 100% rename from test/unit_test/test_serial_selection.cc rename to test/unit_test/legacy/common/test_serial_selection.cc diff --git a/test/unit_test/test_service_helper.cc b/test/unit_test/legacy/common/test_service_helper.cc similarity index 100% rename from test/unit_test/test_service_helper.cc rename to test/unit_test/legacy/common/test_service_helper.cc diff --git a/test/unit_test/test_split_checker.cc b/test/unit_test/legacy/common/test_split_checker.cc similarity index 100% rename from test/unit_test/test_split_checker.cc rename to test/unit_test/legacy/common/test_split_checker.cc diff --git a/test/unit_test/test_store_meta_manager.cc b/test/unit_test/legacy/common/test_store_meta_manager.cc similarity index 100% rename from test/unit_test/test_store_meta_manager.cc rename to test/unit_test/legacy/common/test_store_meta_manager.cc diff --git a/test/unit_test/test_store_metrics_manager.cc b/test/unit_test/legacy/common/test_store_metrics_manager.cc similarity index 100% rename from test/unit_test/test_store_metrics_manager.cc rename to test/unit_test/legacy/common/test_store_metrics_manager.cc diff --git a/test/unit_test/test_threadpool.cc b/test/unit_test/legacy/common/test_threadpool.cc similarity index 100% rename from test/unit_test/test_threadpool.cc rename to test/unit_test/legacy/common/test_threadpool.cc diff --git a/test/unit_test/test_tracker.cc b/test/unit_test/legacy/common/test_tracker.cc similarity index 100% rename from test/unit_test/test_tracker.cc rename to test/unit_test/legacy/common/test_tracker.cc diff --git a/test/unit_test/test_txn_gc.cc b/test/unit_test/legacy/common/test_txn_gc.cc similarity index 100% rename from test/unit_test/test_txn_gc.cc rename to test/unit_test/legacy/common/test_txn_gc.cc diff --git a/test/unit_test/test_txn_scan.cc b/test/unit_test/legacy/common/test_txn_scan.cc similarity index 100% rename from test/unit_test/test_txn_scan.cc rename to test/unit_test/legacy/common/test_txn_scan.cc diff --git a/test/unit_test/test_uuid.cc b/test/unit_test/legacy/common/test_uuid.cc similarity index 100% rename from test/unit_test/test_uuid.cc rename to test/unit_test/legacy/common/test_uuid.cc diff --git a/test/unit_test/test_worker_set.cc b/test/unit_test/legacy/common/test_worker_set.cc similarity index 100% rename from test/unit_test/test_worker_set.cc rename to test/unit_test/legacy/common/test_worker_set.cc diff --git a/test/unit_test/test_write_data.cc b/test/unit_test/legacy/common/test_write_data.cc similarity index 100% rename from test/unit_test/test_write_data.cc rename to test/unit_test/legacy/common/test_write_data.cc diff --git a/test/unit_test/test_yaml_config.cc b/test/unit_test/legacy/common/test_yaml_config.cc similarity index 100% rename from test/unit_test/test_yaml_config.cc rename to test/unit_test/legacy/common/test_yaml_config.cc diff --git a/test/unit_test/test_vector_index.cc b/test/unit_test/legacy/vector/test_vector_index.cc similarity index 100% rename from test/unit_test/test_vector_index.cc rename to test/unit_test/legacy/vector/test_vector_index.cc diff --git a/test/unit_test/test_vector_index_flat.cc b/test/unit_test/legacy/vector/test_vector_index_flat.cc similarity index 100% rename from test/unit_test/test_vector_index_flat.cc rename to test/unit_test/legacy/vector/test_vector_index_flat.cc diff --git a/test/unit_test/test_vector_index_flat_search_limit.cc b/test/unit_test/legacy/vector/test_vector_index_flat_search_limit.cc similarity index 100% rename from test/unit_test/test_vector_index_flat_search_limit.cc rename to test/unit_test/legacy/vector/test_vector_index_flat_search_limit.cc diff --git a/test/unit_test/test_vector_index_flat_search_param.cc b/test/unit_test/legacy/vector/test_vector_index_flat_search_param.cc similarity index 100% rename from test/unit_test/test_vector_index_flat_search_param.cc rename to test/unit_test/legacy/vector/test_vector_index_flat_search_param.cc diff --git a/test/unit_test/test_vector_index_hnsw.cc b/test/unit_test/legacy/vector/test_vector_index_hnsw.cc similarity index 100% rename from test/unit_test/test_vector_index_hnsw.cc rename to test/unit_test/legacy/vector/test_vector_index_hnsw.cc diff --git a/test/unit_test/test_vector_index_hnsw_search_param.cc b/test/unit_test/legacy/vector/test_vector_index_hnsw_search_param.cc similarity index 100% rename from test/unit_test/test_vector_index_hnsw_search_param.cc rename to test/unit_test/legacy/vector/test_vector_index_hnsw_search_param.cc diff --git a/test/unit_test/test_vector_index_ivf_flat.cc b/test/unit_test/legacy/vector/test_vector_index_ivf_flat.cc similarity index 100% rename from test/unit_test/test_vector_index_ivf_flat.cc rename to test/unit_test/legacy/vector/test_vector_index_ivf_flat.cc diff --git a/test/unit_test/test_vector_index_ivf_pq.cc b/test/unit_test/legacy/vector/test_vector_index_ivf_pq.cc similarity index 100% rename from test/unit_test/test_vector_index_ivf_pq.cc rename to test/unit_test/legacy/vector/test_vector_index_ivf_pq.cc diff --git a/test/unit_test/test_vector_index_memory.cc b/test/unit_test/legacy/vector/test_vector_index_memory.cc similarity index 100% rename from test/unit_test/test_vector_index_memory.cc rename to test/unit_test/legacy/vector/test_vector_index_memory.cc diff --git a/test/unit_test/test_vector_index_memory_flat.cc b/test/unit_test/legacy/vector/test_vector_index_memory_flat.cc similarity index 100% rename from test/unit_test/test_vector_index_memory_flat.cc rename to test/unit_test/legacy/vector/test_vector_index_memory_flat.cc diff --git a/test/unit_test/test_vector_index_memory_hnsw.cc b/test/unit_test/legacy/vector/test_vector_index_memory_hnsw.cc similarity index 100% rename from test/unit_test/test_vector_index_memory_hnsw.cc rename to test/unit_test/legacy/vector/test_vector_index_memory_hnsw.cc diff --git a/test/unit_test/test_vector_index_raw_ivf_pq.cc b/test/unit_test/legacy/vector/test_vector_index_raw_ivf_pq.cc similarity index 100% rename from test/unit_test/test_vector_index_raw_ivf_pq.cc rename to test/unit_test/legacy/vector/test_vector_index_raw_ivf_pq.cc diff --git a/test/unit_test/test_vector_index_raw_ivf_pq_boundary.cc b/test/unit_test/legacy/vector/test_vector_index_raw_ivf_pq_boundary.cc similarity index 100% rename from test/unit_test/test_vector_index_raw_ivf_pq_boundary.cc rename to test/unit_test/legacy/vector/test_vector_index_raw_ivf_pq_boundary.cc diff --git a/test/unit_test/test_vector_index_recall_flat.cc b/test/unit_test/legacy/vector/test_vector_index_recall_flat.cc similarity index 100% rename from test/unit_test/test_vector_index_recall_flat.cc rename to test/unit_test/legacy/vector/test_vector_index_recall_flat.cc diff --git a/test/unit_test/test_vector_index_snapshot.cc b/test/unit_test/legacy/vector/test_vector_index_snapshot.cc similarity index 100% rename from test/unit_test/test_vector_index_snapshot.cc rename to test/unit_test/legacy/vector/test_vector_index_snapshot.cc diff --git a/test/unit_test/test_vector_index_utils.cc b/test/unit_test/legacy/vector/test_vector_index_utils.cc similarity index 100% rename from test/unit_test/test_vector_index_utils.cc rename to test/unit_test/legacy/vector/test_vector_index_utils.cc diff --git a/test/unit_test/test_vector_reader.cc b/test/unit_test/legacy/vector/test_vector_reader.cc similarity index 100% rename from test/unit_test/test_vector_reader.cc rename to test/unit_test/legacy/vector/test_vector_reader.cc