lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Ganyo <scott.ga...@eTapestry.com>
Subject Proposed fix for RangeQuery
Date Wed, 10 Oct 2001 21:15:43 GMT
This is to fix a problem with an inclusive range query running one term past
past the upper term when the upper term was not found in the index.

Index: RangeQuery.java
===================================================================
RCS file:
/home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/RangeQuery.java,v
retrieving revision 1.1
diff -u -w -r1.1 RangeQuery.java
--- RangeQuery.java	2001/09/25 21:53:20	1.1
+++ RangeQuery.java	2001/10/10 21:05:48
@@ -169,13 +169,16 @@
                         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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message