You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sa...@apache.org on 2015/05/13 17:41:28 UTC

svn commit: r1679229 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/core/ solr/core/src/java/org/apache/solr/schema/ solr/core/src/test-files/solr/collection1/conf/ solr/core/src/test/org/apache/solr/rest/schema/

Author: sarowe
Date: Wed May 13 15:41:28 2015
New Revision: 1679229

URL: http://svn.apache.org/r1679229
Log:
SOLR-7542: Schema API: Can't remove single dynamic copy field directive (merged trunk r1679225)

Added:
    lucene/dev/branches/branch_5x/solr/core/src/test-files/solr/collection1/conf/schema-single-dynamic-copy-field.xml
      - copied unchanged from r1679225, lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/schema-single-dynamic-copy-field.xml
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/rest/schema/TestRemoveLastDynamicCopyField.java
      - copied unchanged from r1679225, lucene/dev/trunk/solr/core/src/test/org/apache/solr/rest/schema/TestRemoveLastDynamicCopyField.java
Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/solr/   (props changed)
    lucene/dev/branches/branch_5x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_5x/solr/core/   (props changed)
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/IndexSchema.java

Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1679229&r1=1679228&r2=1679229&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Wed May 13 15:41:28 2015
@@ -202,6 +202,9 @@ Bug Fixes
 
 * SOLR-7531: config API shows a few keys merged together (Noble Paul)
 
+* SOLR-7542: Schema API: Can't remove single dynamic copy field directive
+  (Steve Rowe)
+
 Optimizations
 ----------------------
 

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/IndexSchema.java?rev=1679229&r1=1679228&r2=1679229&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/IndexSchema.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/IndexSchema.java Wed May 13 15:41:28 2015
@@ -1324,9 +1324,11 @@ public class IndexSchema {
         }
       }
     }
-    for (DynamicCopy dynamicCopy : dynamicCopyFields) {
-      if (dynamicCopy.getDestFieldName().equals(destField)) {
-        fieldNames.add(dynamicCopy.getRegex());
+    if (null != dynamicCopyFields) {
+      for (DynamicCopy dynamicCopy : dynamicCopyFields) {
+        if (dynamicCopy.getDestFieldName().equals(destField)) {
+          fieldNames.add(dynamicCopy.getRegex());
+        }
       }
     }
     return fieldNames;
@@ -1341,9 +1343,11 @@ public class IndexSchema {
   // This is useful when we need the maxSize param of each CopyField
   public List<CopyField> getCopyFieldsList(final String sourceField){
     final List<CopyField> result = new ArrayList<>();
-    for (DynamicCopy dynamicCopy : dynamicCopyFields) {
-      if (dynamicCopy.matches(sourceField)) {
-        result.add(new CopyField(getField(sourceField), dynamicCopy.getTargetField(sourceField), dynamicCopy.maxChars));
+    if (null != dynamicCopyFields) {
+      for (DynamicCopy dynamicCopy : dynamicCopyFields) {
+        if (dynamicCopy.matches(sourceField)) {
+          result.add(new CopyField(getField(sourceField), dynamicCopy.getTargetField(sourceField), dynamicCopy.maxChars));
+        }
       }
     }
     List<CopyField> fixedCopyFields = copyFieldsMap.get(sourceField);
@@ -1447,46 +1451,48 @@ public class IndexSchema {
         }
       }
     }
-    for (IndexSchema.DynamicCopy dynamicCopy : dynamicCopyFields) {
-      final String source = dynamicCopy.getRegex();
-      final String destination = dynamicCopy.getDestFieldName();
-      if (   (null == requestedSourceFields      || requestedSourceFields.contains(source))
-          && (null == requestedDestinationFields || requestedDestinationFields.contains(destination))) {
-        SimpleOrderedMap<Object> dynamicCopyProps = new SimpleOrderedMap<>();
-
-        dynamicCopyProps.add(SOURCE, dynamicCopy.getRegex());
-        if (showDetails) {
-          IndexSchema.DynamicField sourceDynamicBase = dynamicCopy.getSourceDynamicBase();
-          if (null != sourceDynamicBase) {
-            dynamicCopyProps.add(SOURCE_DYNAMIC_BASE, sourceDynamicBase.getRegex());
-          } else if (source.contains("*")) {
-            List<String> sourceExplicitFields = new ArrayList<>();
-            Pattern pattern = Pattern.compile(source.replace("*", ".*"));   // glob->regex
-            for (String field : fields.keySet()) {
-              if (pattern.matcher(field).matches()) {
-                sourceExplicitFields.add(field);
+    if (null != dynamicCopyFields) {
+      for (IndexSchema.DynamicCopy dynamicCopy : dynamicCopyFields) {
+        final String source = dynamicCopy.getRegex();
+        final String destination = dynamicCopy.getDestFieldName();
+        if ((null == requestedSourceFields || requestedSourceFields.contains(source))
+            && (null == requestedDestinationFields || requestedDestinationFields.contains(destination))) {
+          SimpleOrderedMap<Object> dynamicCopyProps = new SimpleOrderedMap<>();
+
+          dynamicCopyProps.add(SOURCE, dynamicCopy.getRegex());
+          if (showDetails) {
+            IndexSchema.DynamicField sourceDynamicBase = dynamicCopy.getSourceDynamicBase();
+            if (null != sourceDynamicBase) {
+              dynamicCopyProps.add(SOURCE_DYNAMIC_BASE, sourceDynamicBase.getRegex());
+            } else if (source.contains("*")) {
+              List<String> sourceExplicitFields = new ArrayList<>();
+              Pattern pattern = Pattern.compile(source.replace("*", ".*"));   // glob->regex
+              for (String field : fields.keySet()) {
+                if (pattern.matcher(field).matches()) {
+                  sourceExplicitFields.add(field);
+                }
+              }
+              if (sourceExplicitFields.size() > 0) {
+                Collections.sort(sourceExplicitFields);
+                dynamicCopyProps.add(SOURCE_EXPLICIT_FIELDS, sourceExplicitFields);
               }
             }
-            if (sourceExplicitFields.size() > 0) {
-              Collections.sort(sourceExplicitFields);
-              dynamicCopyProps.add(SOURCE_EXPLICIT_FIELDS, sourceExplicitFields);
+          }
+
+          dynamicCopyProps.add(DESTINATION, dynamicCopy.getDestFieldName());
+          if (showDetails) {
+            IndexSchema.DynamicField destDynamicBase = dynamicCopy.getDestDynamicBase();
+            if (null != destDynamicBase) {
+              dynamicCopyProps.add(DESTINATION_DYNAMIC_BASE, destDynamicBase.getRegex());
             }
           }
-        }
-        
-        dynamicCopyProps.add(DESTINATION, dynamicCopy.getDestFieldName());
-        if (showDetails) {
-          IndexSchema.DynamicField destDynamicBase = dynamicCopy.getDestDynamicBase();
-          if (null != destDynamicBase) {
-            dynamicCopyProps.add(DESTINATION_DYNAMIC_BASE, destDynamicBase.getRegex());
+
+          if (0 != dynamicCopy.getMaxChars()) {
+            dynamicCopyProps.add(MAX_CHARS, dynamicCopy.getMaxChars());
           }
-        }
 
-        if (0 != dynamicCopy.getMaxChars()) {
-          dynamicCopyProps.add(MAX_CHARS, dynamicCopy.getMaxChars());
+          copyFieldProperties.add(dynamicCopyProps);
         }
-
-        copyFieldProperties.add(dynamicCopyProps);
       }
     }
     return copyFieldProperties;