jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r536145 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene: ChildAxisQuery.java DefaultXMLExcerpt.java DerefQuery.java DescendantSelfAxisQuery.java NotQuery.java ParentAxisQuery.java
Date Tue, 08 May 2007 10:00:20 GMT
Author: mreutegg
Date: Tue May  8 03:00:19 2007
New Revision: 536145

URL: http://svn.apache.org/viewvc?view=rev&rev=536145
Log:
JCR-900: Lucene queries are not properly rewritten

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DefaultXMLExcerpt.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java?view=diff&rev=536145&r1=536144&r2=536145
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
Tue May  8 03:00:19 2007
@@ -56,7 +56,7 @@
     /**
      * The context query
      */
-    private final Query contextQuery;
+    private Query contextQuery;
 
     /**
      * The nameTest to apply on the child axis, or <code>null</code> if all
@@ -127,6 +127,18 @@
      */
     public void extractTerms(Set terms) {
         contextQuery.extractTerms(terms);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Query rewrite(IndexReader reader) throws IOException {
+        Query cQuery = contextQuery.rewrite(reader);
+        if (cQuery == contextQuery) {
+            return this;
+        } else {
+            return new ChildAxisQuery(itemMgr, cQuery, nameTest, position);
+        }
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DefaultXMLExcerpt.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DefaultXMLExcerpt.java?view=diff&rev=536145&r1=536144&r2=536145
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DefaultXMLExcerpt.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DefaultXMLExcerpt.java
Tue May  8 03:00:19 2007
@@ -54,6 +54,11 @@
     private Query query;
 
     /**
+     * Indicates whether the query is already rewritten.
+     */
+    private boolean rewritten = false;
+
+    /**
      * {@inheritDoc}
      */
     public void init(Query query, SearchIndex index) throws IOException {
@@ -68,6 +73,10 @@
             throws IOException {
         IndexReader reader = index.getIndexReader();
         try {
+            if (!rewritten) {
+                query = query.rewrite(reader);
+                rewritten = true;
+            }
             Term idTerm = new Term(FieldNames.UUID, id.getUUID().toString());
             TermDocs tDocs = reader.termDocs(idTerm);
             int docNumber;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java?view=diff&rev=536145&r1=536144&r2=536145
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
Tue May  8 03:00:19 2007
@@ -109,6 +109,18 @@
         // no terms to extract
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    public Query rewrite(IndexReader reader) throws IOException {
+        Query cQuery = contextQuery.rewrite(reader);
+        if (cQuery == contextQuery) {
+            return this;
+        } else {
+            return new DerefQuery(cQuery, refProperty, nameTest);
+        }
+    }
+
     //-------------------< DerefWeight >------------------------------------
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java?view=diff&rev=536145&r1=536144&r2=536145
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
Tue May  8 03:00:19 2007
@@ -117,6 +117,19 @@
         subQuery.extractTerms(terms);
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    public Query rewrite(IndexReader reader) throws IOException {
+        Query cQuery = contextQuery.rewrite(reader);
+        Query sQuery = subQuery.rewrite(reader);
+        if (cQuery == contextQuery && sQuery == subQuery) {
+            return this;
+        } else {
+            return new DescendantSelfAxisQuery(cQuery, sQuery, includeSelf);
+        }
+    }
+
     //------------------------< DescendantSelfAxisWeight >--------------------------
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java?view=diff&rev=536145&r1=536144&r2=536145
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
Tue May  8 03:00:19 2007
@@ -75,6 +75,18 @@
     }
 
     /**
+     * {@inheritDoc}
+     */
+    public Query rewrite(IndexReader reader) throws IOException {
+        Query cQuery = context.rewrite(reader);
+        if (cQuery == context) {
+            return this;
+        } else {
+            return new NotQuery(cQuery);
+        }
+    }
+
+    /**
      * Implements a weight for this <code>NotQuery</code>.
      */
     private class NotQueryWeight implements Weight {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java?view=diff&rev=536145&r1=536144&r2=536145
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java
Tue May  8 03:00:19 2007
@@ -90,6 +90,18 @@
     }
 
     /**
+     * {@inheritDoc}
+     */
+    public Query rewrite(IndexReader reader) throws IOException {
+        Query cQuery = contextQuery.rewrite(reader);
+        if (cQuery == contextQuery) {
+            return this;
+        } else {
+            return new ParentAxisQuery(cQuery, nameTest);
+        }
+    }
+
+    /**
      * Always returns 'ParentAxisQuery'.
      *
      * @param field the name of a field.



Mime
View raw message