jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r831879 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene: FieldNames.java JackrabbitIndexSearcher.java
Date Mon, 02 Nov 2009 12:43:52 GMT
Author: mreutegg
Date: Mon Nov  2 12:43:51 2009
New Revision: 831879

URL: http://svn.apache.org/viewvc?rev=831879&view=rev
Log:
JCR-2377: Avoid docFreq calls for non-fulltext queries

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FieldNames.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JackrabbitIndexSearcher.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FieldNames.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FieldNames.java?rev=831879&r1=831878&r2=831879&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FieldNames.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FieldNames.java
Mon Nov  2 12:43:51 2009
@@ -152,4 +152,18 @@
     public static int getNameLength(String namedValue) {
         return namedValue.indexOf('[') + 1;
     }
+
+    /**
+     * Returns <code>true</code> if the given <code>fieldName</code>
denotes a
+     * fulltext field like {@link #FULLTEXT} or a field with a
+     * {@link #FULLTEXT_PREFIX}.
+     *
+     * @param fieldName a field name.
+     * @return <code>true</code> if <code>fieldName</code> is a fulltext
field;
+     *         <code>false</code> otherwise.
+     */
+    public static boolean isFulltextField(String fieldName) {
+        return fieldName.equals(FULLTEXT)
+                || fieldName.indexOf(FULLTEXT_PREFIX) != -1;
+    }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JackrabbitIndexSearcher.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JackrabbitIndexSearcher.java?rev=831879&r1=831878&r2=831879&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JackrabbitIndexSearcher.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JackrabbitIndexSearcher.java
Mon Nov  2 12:43:51 2009
@@ -16,16 +16,17 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.Sort;
-import org.apache.lucene.index.IndexReader;
-import org.apache.jackrabbit.core.query.lucene.constraint.EvaluationContext;
+import java.io.IOException;
+
 import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.query.lucene.constraint.EvaluationContext;
 import org.apache.jackrabbit.core.state.ItemStateManager;
 import org.apache.jackrabbit.spi.Name;
-
-import java.io.IOException;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Sort;
 
 /**
  * <code>JackrabbitIndexSearcher</code> implements an index searcher with
@@ -112,6 +113,19 @@
         return hits;
     }
 
+    //---------------------------< IndexSearcher >------------------------------
+
+    @Override
+    public int docFreq(Term term) throws IOException {
+        // provide a fixed document frequency for fields that are not fulltext
+        // indexed. correct frequency is only useful for fulltext queries.
+        if (FieldNames.isFulltextField(term.field())) {
+            return super.docFreq(term);
+        } else {
+            return 1;
+        }
+    }
+
     //------------------------< EvaluationContext >-----------------------------
 
     /**



Mime
View raw message