From f0dae814949a2fa9330067c4f226bafda6b6498a Mon Sep 17 00:00:00 2001 From: Gao Date: Wed, 8 Jan 2025 12:56:56 +0800 Subject: [PATCH] fix: set iterative filter hint to false when no expr specified (#39033) issue: https://github.com/milvus-io/milvus/issues/39013 Signed-off-by: chasingegg --- internal/core/src/query/PlanProto.cpp | 2 + .../core/unittest/test_iterative_filter.cpp | 41 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/internal/core/src/query/PlanProto.cpp b/internal/core/src/query/PlanProto.cpp index 85afac533c22c..05c0074016f16 100644 --- a/internal/core/src/query/PlanProto.cpp +++ b/internal/core/src/query/PlanProto.cpp @@ -186,6 +186,8 @@ ProtoParser::PlanNodeFromProto(const planpb::PlanNode& plan_node_proto) { pre_filter_plan(); } } else { + // no filter, force set iterative filter hint to false, go with normal vector search path + plan_node->search_info_.iterative_filter_execution = false; plannode = std::make_shared( milvus::plan::GetNextPlanNodeId(), sources); sources = std::vector{plannode}; diff --git a/internal/core/unittest/test_iterative_filter.cpp b/internal/core/unittest/test_iterative_filter.cpp index d8df0b3a29d22..e4fbde3033fb8 100644 --- a/internal/core/unittest/test_iterative_filter.cpp +++ b/internal/core/unittest/test_iterative_filter.cpp @@ -253,6 +253,47 @@ TEST(IterativeFilter, SealedIndex) { CheckFilterSearchResult( *search_result, *search_result2, topK, num_queries); } + + // no expr + { + const char* raw_plan = R"(vector_anns: < + field_id: 100 + query_info: < + topk: 10 + metric_type: "L2" + hints: "iterative_filter" + search_params: "{\"ef\": 50}" + > + placeholder_tag: "$0">)"; + proto::plan::PlanNode plan_node; + auto ok = + google::protobuf::TextFormat::ParseFromString(raw_plan, &plan_node); + auto plan = CreateSearchPlanFromPlanNode(*schema, plan_node); + auto num_queries = 1; + auto seed = 1024; + auto ph_group_raw = CreatePlaceholderGroup(num_queries, dim, seed); + auto ph_group = + ParsePlaceholderGroup(plan.get(), ph_group_raw.SerializeAsString()); + auto search_result = + segment->Search(plan.get(), ph_group.get(), 1L << 63); + + const char* raw_plan2 = R"(vector_anns: < + field_id: 100 + query_info: < + topk: 10 + metric_type: "L2" + search_params: "{\"ef\": 50}" + > + placeholder_tag: "$0">)"; + proto::plan::PlanNode plan_node2; + auto ok2 = google::protobuf::TextFormat::ParseFromString(raw_plan2, + &plan_node2); + auto plan2 = CreateSearchPlanFromPlanNode(*schema, plan_node2); + auto search_result2 = + segment->Search(plan2.get(), ph_group.get(), 1L << 63); + CheckFilterSearchResult( + *search_result, *search_result2, topK, num_queries); + } } TEST(IterativeFilter, SealedData) {