Initialize to non-hit.
@@ -81,14 +81,16 @@ SearchIterator::and_hits_into(BitVector &result, uint32_t begin_id)
void
SearchIterator::andnot_hits_into(BitVector &result, uint32_t begin_id)
{
- uint32_t docidA = std::max(begin_id, getDocId());
+ uint32_t docidA = begin_id - 1;
uint32_t docidB = result.getNextTrueBit(begin_id);
while (!isAtEnd(docidA) && !isAtEnd(docidB)) {
if (docidA < docidB) {
if (seek(docidB)) {
docidA = docidB;
+ } else if (getDocId() > docidB) {
+ docidA = getDocId();
} else {
- docidA = std::max(docidB+1, getDocId());
+ docidB = result.getNextTrueBit(docidB+1);
}
} else if (docidA > docidB) {
docidB = result.getNextTrueBit(docidA);
