aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/queryeval
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2021-10-01 10:30:09 +0000
committerHåvard Pettersen <havardpe@oath.com>2021-10-01 10:51:39 +0000
commit0fad251ccd7241f9e4b905935398891ef1800d72 (patch)
treea3fc5d9cf43008ba29923df089adb66d93030eda /searchlib/src/tests/queryeval
parent284a23842b642917a4f380f36a9416af1e9f8ec7 (diff)
use saturated sum as hit estimate for OR
The upper bound for the hit estimate is the docid limit. The lower bound for the docid limit is the maximum child estimate. In the future we probably want a solution where everyone knows the docid limit from the start, which might also require us to have a separate way of estimating the document frequency if we want to avoid ranking score regression.
Diffstat (limited to 'searchlib/src/tests/queryeval')
-rw-r--r--searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp b/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp
index eb6e49747a1..802aee8dee0 100644
--- a/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp
+++ b/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp
@@ -1453,4 +1453,20 @@ TEST("require that intermediate cost tier is minimum cost tier of children") {
EXPECT_EQUAL(bp2->getState().cost_tier(), 2u);
}
+void verify_or_est(const std::vector<Blueprint::HitEstimate> &child_estimates, Blueprint::HitEstimate expect) {
+ OrBlueprint my_or;
+ my_or.setDocIdLimit(32);
+ auto my_est = my_or.combine(child_estimates);
+ EXPECT_EQUAL(my_est.empty, expect.empty);
+ EXPECT_EQUAL(my_est.estHits, expect.estHits);
+}
+
+TEST("require that OR blueprint use saturated sum as estimate") {
+ TEST_DO(verify_or_est({{0, true},{0, true},{0, true}}, {0, true}));
+ TEST_DO(verify_or_est({{0, true},{0, false},{0, true}}, {0, false}));
+ TEST_DO(verify_or_est({{4, false},{6, false},{5, false}}, {15, false}));
+ TEST_DO(verify_or_est({{5, false},{20, false},{10, false}}, {32, false}));
+ TEST_DO(verify_or_est({{100, false},{300, false},{200, false}}, {300, false}));
+}
+
TEST_MAIN() { TEST_DEBUG("lhs.out", "rhs.out"); TEST_RUN_ALL(); }