Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

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

Scott Ganyo4c3e4ce6858e
diff --git a/src/java/org/apache/lucene/search/RangeQuery.java b/src/java/org/apache/lucene/search/RangeQuery.java
index 5464238b6c8..d84d6ef9706 100644
--- a/src/java/org/apache/lucene/search/RangeQuery.java
+++ b/src/java/org/apache/lucene/search/RangeQuery.java
@@ -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