scottganyo    01/10/11 08:19:38

  Modified:    src/java/org/apache/lucene/search RangeQuery.java
  Log:
  Fix issue where an inclusive range query would include the nearest term in the index 
above a non-existant specified upper term.
  
  Revision  Changes    Path
  1.2       +7 -4      jakarta-lucene/src/java/org/apache/lucene/search/RangeQuery.java
  
  Index: RangeQuery.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/RangeQuery.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RangeQuery.java   2001/09/25 21:53:20     1.1
  +++ RangeQuery.java   2001/10/11 15:19:37     1.2
  @@ -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
  
  
  


Reply via email to