You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2011/04/21 13:34:15 UTC

svn commit: r1095660 - in /jackrabbit/branches/2.2: ./ RELEASE-NOTES.txt jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java

Author: jukka
Date: Thu Apr 21 11:34:15 2011
New Revision: 1095660

URL: http://svn.apache.org/viewvc?rev=1095660&view=rev
Log:
2.2: Merged revision 1089053 (JCR-2917)

Modified:
    jackrabbit/branches/2.2/   (props changed)
    jackrabbit/branches/2.2/RELEASE-NOTES.txt
    jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java

Propchange: jackrabbit/branches/2.2/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Apr 21 11:34:15 2011
@@ -2,4 +2,4 @@
 /jackrabbit/sandbox/JCR-1456:774917-886178
 /jackrabbit/sandbox/JCR-2170:812417-816332
 /jackrabbit/sandbox/tripod-JCR-2209:795441-795863
-/jackrabbit/trunk:1038201,1038203,1038205,1038657,1039064,1039347,1039408,1039422-1039423,1039888,1039946,1040033,1040090,1040459,1040601,1040606,1040661,1040958,1041379,1041439,1041761,1042643,1042647,1042978-1042982,1043084-1043086,1043088,1043343,1043357-1043358,1043430,1043554,1043616,1043618,1043637,1043656,1043893,1043897,1044239,1044312,1044451,1044613,1049473,1049491,1049514,1049518,1049520,1049859,1049870,1049874,1049878,1049880,1049883,1049889,1049891,1049894-1049895,1049899-1049901,1049909-1049911,1049915-1049916,1049919,1049923,1049925,1049931,1049936,1049939,1050212,1050298,1050346,1050551,1055068,1055070-1055071,1055116-1055117,1055127,1055134,1055164,1055498,1060431,1060434,1060753,1063756,1065599,1065622,1066059,1066071,1069831,1071562,1071573,1071680,1074140,1079314,1079317,1087304,1089032,1089436
+/jackrabbit/trunk:1038201,1038203,1038205,1038657,1039064,1039347,1039408,1039422-1039423,1039888,1039946,1040033,1040090,1040459,1040601,1040606,1040661,1040958,1041379,1041439,1041761,1042643,1042647,1042978-1042982,1043084-1043086,1043088,1043343,1043357-1043358,1043430,1043554,1043616,1043618,1043637,1043656,1043893,1043897,1044239,1044312,1044451,1044613,1049473,1049491,1049514,1049518,1049520,1049859,1049870,1049874,1049878,1049880,1049883,1049889,1049891,1049894-1049895,1049899-1049901,1049909-1049911,1049915-1049916,1049919,1049923,1049925,1049931,1049936,1049939,1050212,1050298,1050346,1050551,1055068,1055070-1055071,1055116-1055117,1055127,1055134,1055164,1055498,1060431,1060434,1060753,1063756,1065599,1065622,1066059,1066071,1069831,1071562,1071573,1071680,1074140,1079314,1079317,1087304,1089032,1089053,1089436

Modified: jackrabbit/branches/2.2/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/RELEASE-NOTES.txt?rev=1095660&r1=1095659&r2=1095660&view=diff
==============================================================================
--- jackrabbit/branches/2.2/RELEASE-NOTES.txt (original)
+++ jackrabbit/branches/2.2/RELEASE-NOTES.txt Thu Apr 21 11:34:15 2011
@@ -18,6 +18,7 @@ Bug fixes
 
   [JCR-2880] Save fails after setting a binary property twice
   [JCR-2890] Deadlock in acl.EntryCollector / ItemManager
+  [JCR-2917] Indexing configuration ignored when indexing length
 
 For more detailed information about all the changes in this and other
 Jackrabbit releases, please see the Jackrabbit issue tracker at

Modified: jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java?rev=1095660&r1=1095659&r2=1095660&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java (original)
+++ jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java Thu Apr 21 11:34:15 2011
@@ -20,7 +20,6 @@ import java.math.BigDecimal;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Calendar;
-import java.util.Date;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.Executor;
@@ -391,11 +390,31 @@ public class NodeIndexer {
                     addDecimalValue(doc, fieldName, value.getDecimal());
                 }
                 break;
-
-
             default:
                 throw new IllegalArgumentException("illegal internal value type: " + value.getType());
         }
+        addValueProperty(doc, value, name, fieldName);
+    }
+
+    /**
+     * Adds a property related value to the lucene Document. <br>
+     *
+     * Like <code>length</code> for indexed fields.
+     *
+     * @param doc
+     *            the document.
+     * @param value
+     *            the internal jackrabbit value.
+     * @param name
+     *            the name of the property.
+     */
+    protected void addValueProperty(Document doc, InternalValue value,
+            Name name, String fieldName) throws RepositoryException {
+
+        // skip this method if field is not indexed
+        if (!isIndexed(name)) {
+            return;
+        }
 
         // add length
         if (indexFormatVersion.getVersion() >= IndexFormatVersion.V3.getVersion()) {
@@ -539,15 +558,14 @@ public class NodeIndexer {
      * @param internalValue
      *            The value for the field to add to the document.
      */
-    protected void addCalendarValue(Document doc, String fieldName, Object internalValue) {
-        Calendar value = (Calendar) internalValue;
-        long millis = value.getTimeInMillis();
+    protected void addCalendarValue(Document doc, String fieldName, Calendar internalValue) {
         try {
-            doc.add(createFieldWithoutNorms(fieldName, DateField.timeToString(millis),
+            doc.add(createFieldWithoutNorms(fieldName,
+                    DateField.timeToString(internalValue.getTimeInMillis()),
                     PropertyType.DATE));
         } catch (IllegalArgumentException e) {
             log.warn("'{}' is outside of supported date value range.",
-                    new Date(value.getTimeInMillis()));
+                    internalValue);
         }
     }
 
@@ -560,9 +578,8 @@ public class NodeIndexer {
      * @param fieldName     The name of the field to add
      * @param internalValue The value for the field to add to the document.
      */
-    protected void addDoubleValue(Document doc, String fieldName, Object internalValue) {
-        double doubleVal = (Double) internalValue;
-        doc.add(createFieldWithoutNorms(fieldName, DoubleField.doubleToString(doubleVal),
+    protected void addDoubleValue(Document doc, String fieldName, double internalValue) {
+        doc.add(createFieldWithoutNorms(fieldName, DoubleField.doubleToString(internalValue),
                 PropertyType.DOUBLE));
     }
 
@@ -575,9 +592,8 @@ public class NodeIndexer {
      * @param fieldName     The name of the field to add
      * @param internalValue The value for the field to add to the document.
      */
-    protected void addLongValue(Document doc, String fieldName, Object internalValue) {
-        long longVal = (Long) internalValue;
-        doc.add(createFieldWithoutNorms(fieldName, LongField.longToString(longVal),
+    protected void addLongValue(Document doc, String fieldName, long internalValue) {
+        doc.add(createFieldWithoutNorms(fieldName, LongField.longToString(internalValue),
                 PropertyType.LONG));
     }
 
@@ -590,9 +606,8 @@ public class NodeIndexer {
      * @param fieldName     The name of the field to add
      * @param internalValue The value for the field to add to the document.
      */
-    protected void addDecimalValue(Document doc, String fieldName, Object internalValue) {
-        BigDecimal decVal = (BigDecimal) internalValue;
-        doc.add(createFieldWithoutNorms(fieldName, DecimalField.decimalToString(decVal),
+    protected void addDecimalValue(Document doc, String fieldName, BigDecimal internalValue) {
+        doc.add(createFieldWithoutNorms(fieldName, DecimalField.decimalToString(internalValue),
                 PropertyType.DECIMAL));
     }
 
@@ -608,7 +623,7 @@ public class NodeIndexer {
      * @param internalValue The value for the field to add to the document.
      * @param weak          Flag indicating whether it's a WEAKREFERENCE (true) or a REFERENCE (flase)
      */
-    protected void addReferenceValue(Document doc, String fieldName, Object internalValue, boolean weak) {
+    protected void addReferenceValue(Document doc, String fieldName, NodeId internalValue, boolean weak) {
         String uuid = internalValue.toString();
         doc.add(createFieldWithoutNorms(fieldName, uuid,
                 weak ? PropertyType.WEAKREFERENCE : PropertyType.REFERENCE));
@@ -630,11 +645,10 @@ public class NodeIndexer {
      * @param fieldName     The name of the field to add
      * @param internalValue The value for the field to add to the document.
      */
-    protected void addPathValue(Document doc, String fieldName, Object internalValue) {
-        Path path = (Path) internalValue;
-        String pathString = path.toString();
+    protected void addPathValue(Document doc, String fieldName, Path internalValue) {
+        String pathString = internalValue.toString();
         try {
-            pathString = resolver.getJCRPath(path);
+            pathString = resolver.getJCRPath(internalValue);
         } catch (NamespaceException e) {
             // will never happen
         }
@@ -649,9 +663,8 @@ public class NodeIndexer {
      * @param fieldName     The name of the field to add
      * @param internalValue The value for the field to add to the document.
      */
-    protected void addURIValue(Document doc, String fieldName, Object internalValue) {
-        URI uri = (URI) internalValue;
-        doc.add(createFieldWithoutNorms(fieldName, uri.toString(),
+    protected void addURIValue(Document doc, String fieldName, URI internalValue) {
+        doc.add(createFieldWithoutNorms(fieldName, internalValue.toString(),
                 PropertyType.URI));
     }
 
@@ -665,7 +678,7 @@ public class NodeIndexer {
      * @deprecated Use {@link #addStringValue(Document, String, Object, boolean)
      *             addStringValue(Document, String, Object, boolean)} instead.
      */
-    protected void addStringValue(Document doc, String fieldName, Object internalValue) {
+    protected void addStringValue(Document doc, String fieldName, String internalValue) {
         addStringValue(doc, fieldName, internalValue, true, true, DEFAULT_BOOST);
     }
 
@@ -681,7 +694,7 @@ public class NodeIndexer {
      *                      and fulltext indexed.
      */
     protected void addStringValue(Document doc, String fieldName,
-                                  Object internalValue, boolean tokenized) {
+                                  String internalValue, boolean tokenized) {
         addStringValue(doc, fieldName, internalValue, tokenized, true, DEFAULT_BOOST);
     }
 
@@ -703,7 +716,7 @@ public class NodeIndexer {
      * @deprecated use {@link #addStringValue(Document, String, Object, boolean, boolean, float, boolean)} instead.
      */
     protected void addStringValue(Document doc, String fieldName,
-                                  Object internalValue, boolean tokenized,
+                                  String internalValue, boolean tokenized,
                                   boolean includeInNodeIndex, float boost) {
         addStringValue(doc, fieldName, internalValue, tokenized, includeInNodeIndex, boost, true);
     }
@@ -727,33 +740,30 @@ public class NodeIndexer {
      *                           an excerpt.
      */
     protected void addStringValue(Document doc, String fieldName,
-                                  Object internalValue, boolean tokenized,
+                                  String internalValue, boolean tokenized,
                                   boolean includeInNodeIndex, float boost,
                                   boolean useInExcerpt) {
 
         // simple String
-        String stringValue = (String) internalValue;
-        doc.add(createFieldWithoutNorms(fieldName, stringValue,
+        doc.add(createFieldWithoutNorms(fieldName, internalValue,
                 PropertyType.STRING));
         if (tokenized) {
-            if (stringValue.length() == 0) {
+            if (internalValue.length() == 0) {
                 return;
             }
             // create fulltext index on property
             int idx = fieldName.indexOf(':');
             fieldName = fieldName.substring(0, idx + 1)
                     + FieldNames.FULLTEXT_PREFIX + fieldName.substring(idx + 1);
-            Field f = new Field(fieldName, stringValue,
-                    Field.Store.NO,
-                    Field.Index.ANALYZED,
-                    Field.TermVector.NO);
+            Field f = new Field(fieldName, internalValue, Field.Store.NO,
+                    Field.Index.ANALYZED, Field.TermVector.NO);
             f.setBoost(boost);
             doc.add(f);
 
             if (includeInNodeIndex) {
                 // also create fulltext index of this value
                 boolean store = supportHighlighting && useInExcerpt;
-                f = createFulltextField(stringValue, store, supportHighlighting);
+                f = createFulltextField(internalValue, store, supportHighlighting);
                 if (useInExcerpt) {
                     doc.add(f);
                 } else {
@@ -773,11 +783,10 @@ public class NodeIndexer {
      * @param fieldName     The name of the field to add
      * @param internalValue The value for the field to add to the document.
      */
-    protected void addNameValue(Document doc, String fieldName, Object internalValue) {
+    protected void addNameValue(Document doc, String fieldName, Name internalValue) {
         try {
-            Name qualiName = (Name) internalValue;
-            String normValue = mappings.getPrefix(qualiName.getNamespaceURI())
-                    + ":" + qualiName.getLocalName();
+            String normValue = mappings.getPrefix(internalValue.getNamespaceURI())
+                    + ":" + internalValue.getLocalName();
             doc.add(createFieldWithoutNorms(fieldName, normValue,
                     PropertyType.NAME));
         } catch (NamespaceException e) {