From 4a8b62623adcb20b1e95c66a7e56e9f2402a6e5f Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Mon, 9 Dec 2024 16:53:02 +0100 Subject: [PATCH] Nearest neighbor term operator needs ranking. --- searchcore/src/tests/proton/matching/query_test.cpp | 7 +++++++ searchcore/src/vespa/searchcore/proton/matching/query.cpp | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/searchcore/src/tests/proton/matching/query_test.cpp b/searchcore/src/tests/proton/matching/query_test.cpp index 034aa8b9e62..53772ac0156 100644 --- a/searchcore/src/tests/proton/matching/query_test.cpp +++ b/searchcore/src/tests/proton/matching/query_test.cpp @@ -1183,6 +1183,13 @@ TEST(QueryTest, wand_term_needs_ranking) EXPECT_TRUE(query_needs_ranking(StackDumpCreator::create(*builder.build()))); } +TEST(QueryTest, nearest_neighbor_term_needs_ranking) +{ + QueryBuilder builder; + builder.add_nearest_neighbor_term("qtensor", "f1", 1, Weight(1), 10, true, 100, 1.5); + EXPECT_TRUE(query_needs_ranking(StackDumpCreator::create(*builder.build()))); +} + } // namespace } // namespace proton::matching diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.cpp b/searchcore/src/vespa/searchcore/proton/matching/query.cpp index 8bdf738d3c3..abfaf84f7d0 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/query.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/query.cpp @@ -144,8 +144,8 @@ void exchange_location_nodes(const string &location_str, } /* - * WeakAnd, WeightedSetTerm, DotProduct and WandTerm query operators need ranking since - * doUnpack is used to updated threshold during query evaluation. + * WeakAnd, WandTerm and NearestNeighborTerm query operators need ranking since + * doUnpack is used to update threshold during query evaluation. */ class NeedsRankingVisitor : public TemplateTermVisitor { @@ -159,6 +159,7 @@ class NeedsRankingVisitor : public TemplateTermVisitor void visitTerm(TermNode&) { } void visit(ProtonNodeTypes::WeakAnd&) override { _needs_ranking = true; } void visitTerm(ProtonNodeTypes::WandTerm&) { _needs_ranking = true; } + void visitTerm(ProtonNodeTypes::NearestNeighborTerm&) { _needs_ranking = true; } bool needs_ranking() const noexcept { return _needs_ranking; } };