aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2020-06-07 15:09:43 +0000
committerArne Juul <arnej@verizonmedia.com>2020-06-07 19:17:03 +0000
commit29a4e89c1e85aa1e967586606676bef35a9ad47a (patch)
treea90f59ffea246a988dcdf60571396131545cf5f3 /searchcore
parentc5dbeedb10013c7e5931b5da27d00de5808e50d3 (diff)
compute and apply global filter after fetchPostings
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/query.cpp28
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/query.h1
3 files changed, 21 insertions, 10 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp
index f7fce994bd1..f19b416b92f 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp
@@ -185,6 +185,8 @@ MatchToolsFactory(QueryLimiter & queryLimiter,
_query.optimize();
trace.addEvent(4, "MTF: Fetch Postings");
_query.fetchPostings();
+ trace.addEvent(5, "MTF: Handle Global Filters");
+ _query.handle_global_filters(searchContext.getDocIdLimit());
_query.freeze();
trace.addEvent(5, "MTF: prepareSharedState");
_rankSetup.prepareSharedState(_queryEnv, _queryEnv.getObjectStore());
diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.cpp b/searchcore/src/vespa/searchcore/proton/matching/query.cpp
index d7c0ac04ce5..b12b20d2031 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/query.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/query.cpp
@@ -190,17 +190,7 @@ Query::reserveHandles(const IRequestContext & requestContext, ISearchContext &co
void
Query::optimize()
{
- using search::queryeval::GlobalFilter;
_blueprint = Blueprint::optimize(std::move(_blueprint));
- if (_blueprint->getState().want_global_filter()) {
- auto white_list = (_white_list_provider ?
- _white_list_provider->get_white_list_filter() :
- search::BitVector::UP());
- auto global_filter = GlobalFilter::create(std::move(white_list));
- _blueprint->set_global_filter(*global_filter);
- // optimized order may change after accounting for global filter:
- _blueprint = Blueprint::optimize(std::move(_blueprint));
- }
LOG(debug, "optimized blueprint:\n%s\n", _blueprint->asString().c_str());
}
@@ -211,6 +201,24 @@ Query::fetchPostings()
}
void
+Query::handle_global_filters(uint32_t docid_limit)
+{
+ using search::queryeval::GlobalFilter;
+ if (_blueprint->getState().want_global_filter()) {
+ auto constraint = Blueprint::FilterConstraint::UPPER_BOUND;
+ bool strict = true;
+ auto filter_iterator = _blueprint->createFilterSearch(strict, constraint);
+ filter_iterator->initRange(1, docid_limit);
+ auto white_list = filter_iterator->get_hits(1);
+ auto global_filter = GlobalFilter::create(std::move(white_list));
+ _blueprint->set_global_filter(*global_filter);
+ // optimized order may change after accounting for global filter:
+ _blueprint = Blueprint::optimize(std::move(_blueprint));
+ LOG(debug, "blueprint after handle_global_filters:\n%s\n", _blueprint->asString().c_str());
+ }
+}
+
+void
Query::freeze()
{
_blueprint->freeze();
diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.h b/searchcore/src/vespa/searchcore/proton/matching/query.h
index 4ca66fb7a86..1aecb7136b1 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/query.h
+++ b/searchcore/src/vespa/searchcore/proton/matching/query.h
@@ -93,6 +93,7 @@ public:
**/
void optimize();
void fetchPostings();
+ void handle_global_filters(uint32_t docidLimit);
void freeze();
/**