jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r210089 - /incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
Date Mon, 11 Jul 2005 09:16:17 GMT
Author: mreutegg
Date: Mon Jul 11 02:16:14 2005
New Revision: 210089

URL: http://svn.apache.org/viewcvs?rev=210089&view=rev
Log:
JCR-111: org.apache.lucene.search.BooleanQuery$TooManyClauses when using '>' operator
- Use lucene RangeQuery implementation whenever possible.

Modified:
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java?rev=210089&r1=210088&r2=210089&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
(original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
Mon Jul 11 02:16:14 2005
@@ -22,6 +22,7 @@
 import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.Explanation;
 import org.apache.lucene.search.Similarity;
+import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.TermEnum;
@@ -80,6 +81,26 @@
 
         this.upperTerm = upperTerm;
         this.inclusive = inclusive;
+    }
+
+    /**
+     * Tries to rewrite this query into a standard lucene RangeQuery.
+     * This rewrite might fail with a TooManyClauses exception. If that
+     * happens, we use our own implementation.
+     *
+     * @param reader the index reader.
+     * @return the rewritten query or this query if rewriting is not possible.
+     * @throws IOException if an error occurs.
+     */
+    public Query rewrite(IndexReader reader) throws IOException {
+        Query stdRangeQueryImpl
+                = new org.apache.lucene.search.RangeQuery(lowerTerm, upperTerm, inclusive);
+        try {
+            return stdRangeQueryImpl.rewrite(reader);
+        } catch (BooleanQuery.TooManyClauses e) {
+            // failed, use own implementation
+            return this;
+        }
     }
 
     /**



Mime
View raw message