Fix issue where an inclusive range query would include the nearest term in the index above a non-existant specified upper term.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@149609 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Scott Ganyo 2001-10-11 15:19:37 +00:00
parent e9161ac365
commit 4c3e4ce685
1 changed files with 7 additions and 4 deletions

View File

@ -169,13 +169,16 @@ public final class RangeQuery extends Query
if (!checkLower || term.text().compareTo(lowerText) > 0)
{
checkLower = false;
// if exclusive and this is last term, don't count it and break
if (!inclusive && (upperTerm != null) && (upperTerm.compareTo(term) <= 0)) break;
if (upperTerm != null)
{
int compare = upperTerm.compareTo(term);
/* if beyond the upper term, or is exclusive and
* this is equal to the upper term, break out */
if ((compare < 0) || (!inclusive && compare == 0)) break;
}
TermQuery tq = new TermQuery(term); // found a match
tq.setBoost(boost); // set the boost
q.add(tq, false, false); // add to q
// if inclusive just added last term, break out
if (inclusive && (upperTerm != null) && (upperTerm.compareTo(term) <= 0)) break;
}
}
else