@@ -373,6 +373,42 @@ TEST_CASE_PERSISTENT_FIXTURE(fixtures::PyramidTestIndex,
373373 REQUIRE (ids_a.count (402 ) == 0 );
374374}
375375
376+ TEST_CASE_PERSISTENT_FIXTURE (fixtures::PyramidTestIndex,
377+ " Pyramid KnnSearch Expands Ef Search To Topk" ,
378+ " [ft][build][pyramid]" ) {
379+ PyramidParam pyramid_param;
380+ pyramid_param.no_build_levels = {};
381+
382+ const auto param = GeneratePyramidBuildParametersString (" l2" , 4 , pyramid_param);
383+ auto index = TestFactory (" pyramid" , param, true );
384+
385+ constexpr int64_t data_count = 24 ;
386+ constexpr int64_t topk = 20 ;
387+ constexpr int64_t ef_search = 5 ;
388+ std::vector<std::array<float , 4 >> vectors;
389+ std::vector<int64_t > ids;
390+ std::vector<std::string> paths;
391+ vectors.reserve (data_count);
392+ ids.reserve (data_count);
393+ paths.reserve (data_count);
394+ for (int64_t i = 0 ; i < data_count; ++i) {
395+ auto value = static_cast <float >(i);
396+ vectors.push_back ({value, value + 1 .0F , value + 2 .0F , value + 3 .0F });
397+ ids.push_back (1000 + i);
398+ paths.emplace_back (" all" );
399+ }
400+
401+ auto base = MakeDenseDataset (vectors, ids, paths);
402+ auto build_result = index->Build (base);
403+ REQUIRE (build_result.has_value ());
404+
405+ auto query = MakeSingleQuery (vectors.front (), " all" );
406+ auto search_result =
407+ index->KnnSearch (query, topk, GeneratePyramidSearchParametersString (ef_search));
408+ REQUIRE (search_result.has_value ());
409+ REQUIRE (search_result.value ()->GetDim () == topk);
410+ }
411+
376412TEST_CASE_PERSISTENT_FIXTURE (fixtures::PyramidTestIndex,
377413 " Pyramid Add Test" ,
378414 " [ft][build][pyramid]" ) {
0 commit comments