diff options
3 files changed, 16 insertions, 16 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp index 5a58aa869e0..c434203898e 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp @@ -223,11 +223,6 @@ public: setEstimate(HitEstimate(_activeLids.size(), false)); } - FlowStats calculate_flow_stats(uint32_t docid_limit) const override { - auto est = abs_to_rel_est(getState().estimate().estHits, docid_limit); - return {est, 1.0, est}; - } - bool isWhiteList() const noexcept final { return true; } SearchIterator::UP createFilterSearch(bool strict, FilterConstraint) const override { diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp index 8742f53bc8e..09da4697583 100644 --- a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp @@ -129,6 +129,7 @@ private: // as only a few ISearchContext implementations exposes the query term. vespalib::string _query_term; ISearchContext::UP _search_context; + attribute::HitEstimate _hit_estimate; enum Type {INT, FLOAT, OTHER}; Type _type; @@ -139,6 +140,18 @@ public: QueryTermSimple::UP term, const SearchContextParams ¶ms); ~AttributeFieldBlueprint() override; + search::queryeval::FlowStats calculate_flow_stats(uint32_t docid_limit) const override { + if (_hit_estimate.is_unknown()) { + // E.g. attributes without fast-search are not able to provide a hit estimate. + // In this case we just assume matching half of the document corpus. + // In addition, we are not able to skip documents efficiently when being strict. + return {0.5, 1.0, 1.0}; + } else { + double rel_est = abs_to_rel_est(_hit_estimate.est_hits(), docid_limit); + return {rel_est, 1.0, rel_est}; + } + } + SearchIteratorUP createLeafSearch(const TermFieldMatchDataArray &tfmda, bool strict) const override { assert(tfmda.size() == 1); return _search_context->createIterator(tfmda[0], strict); @@ -182,9 +195,10 @@ AttributeFieldBlueprint::AttributeFieldBlueprint(FieldSpecBase field, const IAtt _attr(attribute), _query_term(term->getTermString()), _search_context(attribute.createSearchContext(std::move(term), params)), + _hit_estimate(_search_context->calc_hit_estimate()), _type(OTHER) { - uint32_t estHits = _search_context->calc_hit_estimate().est_hits(); + uint32_t estHits = _hit_estimate.est_hits(); HitEstimate estimate(estHits, estHits == 0); setEstimate(estimate); if (attribute.isFloatingPointType()) { @@ -194,8 +208,6 @@ AttributeFieldBlueprint::AttributeFieldBlueprint(FieldSpecBase field, const IAtt } } - - void AttributeFieldBlueprint::visitMembers(vespalib::ObjectVisitor &visitor) const { diff --git a/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp index 7f34bc82c03..b05e5cbef3d 100644 --- a/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp @@ -718,14 +718,7 @@ FlowStats LeafBlueprint::calculate_flow_stats(uint32_t docid_limit) const { double rel_est = abs_to_rel_est(_state.estimate().estHits, docid_limit); - if (rel_est > 0.9) { - // Assume we do not really know how much we are matching when - // we claim to match 'everything'. Also assume we are not able - // to skip documents efficiently when strict. - return {0.5, 1.0, 1.0}; - } else { - return {rel_est, 1.0, rel_est}; - } + return {rel_est, 1.0, rel_est}; } void |