summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h10
2 files changed, 13 insertions, 1 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp
index 576506aeea9..b7517094b19 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp
@@ -57,6 +57,10 @@ void
PostingListSearchContext::lookupRange(const vespalib::datastore::EntryComparator &low,
const vespalib::datastore::EntryComparator &high)
{
+ if (!_dictionary.get_has_btree_dictionary()) {
+ _uniqueValues = 2; // Avoid zero and single value optimizations, use filtering
+ return;
+ }
_lowerDictItr.lower_bound(_frozenDictionary.getRoot(), EnumIndex(), low);
_upperDictItr = _lowerDictItr;
if (_upperDictItr.valid() && !high.less(EnumIndex(), _upperDictItr.getKey())) {
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h
index 3777f3cf4ea..22e9987aa9e 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h
@@ -80,6 +80,9 @@ protected:
}
virtual bool fallbackToFiltering() const {
+ if (_uniqueValues >= 2 && !_dictionary.get_has_btree_dictionary()) {
+ return true; // force filtering for range search
+ }
uint32_t numHits = calculateApproxNumHits();
// numHits > 1000: make sure that posting lists are unit tested.
return (numHits > 1000) &&
@@ -216,7 +219,7 @@ private:
bool fallbackToFiltering() const override {
return (this->getRangeLimit() != 0)
- ? false
+ ? (this->_uniqueValues >= 2 && !this->_dictionary.get_has_btree_dictionary())
: Parent::fallbackToFiltering();
}
unsigned int approximateHits() const override {
@@ -339,6 +342,11 @@ getIterators(bool shouldApplyRangeLimit)
auto compHigh = _enumStore.make_comparator(capped.upper());
this->lookupRange(compLow, compHigh);
+ if (!this->_dictionary.get_has_btree_dictionary()) {
+ _low = capped.lower();
+ _high = capped.upper();
+ return;
+ }
if (shouldApplyRangeLimit) {
this->applyRangeLimit(this->getRangeLimit());
}