diff options
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp | 27 | ||||
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/matching/match_thread.h | 1 |
2 files changed, 27 insertions, 1 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp index 81a4b443208..7ccc120d047 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp @@ -381,7 +381,32 @@ MatchThread::findMatches(MatchTools &tools) secondPhase(tools, hits); } trace->addEvent(4, "Create result set"); - return hits.getResultSet(); + if (tools.has_second_phase_rank() && matchParams.second_phase_rank_score_drop_limit.has_value()) { + return get_matches_after_second_phase_rank_score_drop(hits); + } else { + return hits.getResultSet(); + } +} + +std::unique_ptr<search::ResultSet> +MatchThread::get_matches_after_second_phase_rank_score_drop(HitCollector& hits) +{ + std::vector<uint32_t> dropped; + auto result = hits.get_result_set(matchParams.second_phase_rank_score_drop_limit, &dropped); + if (!dropped.empty()) { + /* + * Hits dropped due to second phase rank score drop limit are + * not present in the result. Schedule extra tasks to update + * mutable attributes for earlier match phases. + */ + if (auto task = matchToolsFactory.createOnMatchTask()) { + task->run(dropped); + } + if (auto task = matchToolsFactory.createOnFirstPhaseTask()) { + task->run(std::move(dropped)); + } + } + return result; } void diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_thread.h b/searchcore/src/vespa/searchcore/proton/matching/match_thread.h index b267e7b799c..e017dc53c5c 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_thread.h +++ b/searchcore/src/vespa/searchcore/proton/matching/match_thread.h @@ -113,6 +113,7 @@ private: void match_loop_helper(MatchTools &tools, HitCollector &hits); search::ResultSet::UP findMatches(MatchTools &tools); + std::unique_ptr<search::ResultSet> get_matches_after_second_phase_rank_score_drop(HitCollector& hits); void secondPhase(MatchTools & tools, HitCollector & hits); void processResult(const Doom & doom, search::ResultSet::UP result, ResultProcessor::Context &context); |