You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2016/04/15 09:54:16 UTC

lucene-solr:master: SOLR-8985: Added back support for 'includeDynamic' flag to /schema/fields endpoint

Repository: lucene-solr
Updated Branches:
  refs/heads/master a0bc1e642 -> 9313a6304


 SOLR-8985: Added back support for 'includeDynamic' flag to /schema/fields endpoint


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/9313a630
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/9313a630
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/9313a630

Branch: refs/heads/master
Commit: 9313a6304b3d6560b6dce68ef4c0efaab52b22b8
Parents: a0bc1e6
Author: Noble Paul <no...@apache.org>
Authored: Fri Apr 15 13:23:51 2016 +0530
Committer: Noble Paul <no...@apache.org>
Committed: Fri Apr 15 13:23:51 2016 +0530

----------------------------------------------------------------------
 solr/CHANGES.txt                                  |  2 ++
 .../java/org/apache/solr/schema/IndexSchema.java  | 15 +++++++++++----
 .../rest/schema/TestFieldCollectionResource.java  | 18 ++++++++++++++++--
 3 files changed, 29 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9313a630/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 9987ecb..6152a92 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -164,6 +164,8 @@ Other Changes
 * SOLR-8967: In SolrCloud mode, under the 'Core Selector' dropdown in the UI the Replication tab won't be displayed
   anymore. The Replication tab is only beneficial to users running Solr in master-slave mode. (Varun Thacker)
 
+* SOLR-8985: Added back support for 'includeDynamic' flag to /schema/fields endpoint (noble)
+
 ==================  6.0.0 ==================
 
 Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9313a630/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
index 4319c3e..7f7bd73 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -1385,16 +1385,23 @@ public class IndexSchema {
     for (String fieldName : fieldNames) {
       fieldProperties.add(fields.get(fieldName).getNamedPropertyValues(params.getBool("showDefaults", false)));
     }
+    if (params.getBool("includeDynamic", false)) {
+      fieldProperties.addAll(getDynamicFields(params));
+    }
     topLevel.add(FIELDS, fieldProperties);
+    topLevel.add(DYNAMIC_FIELDS, getDynamicFields(params));
+    topLevel.add(COPY_FIELDS, getCopyFieldProperties(false, null, null));
+    return topLevel;
+  }
+
+  private List<SimpleOrderedMap<Object>> getDynamicFields(SolrParams params) {
     List<SimpleOrderedMap<Object>> dynamicFieldProperties = new ArrayList<>();
-    for (IndexSchema.DynamicField dynamicField : dynamicFields) {
+    for (DynamicField dynamicField : dynamicFields) {
       if ( ! dynamicField.getRegex().startsWith(INTERNAL_POLY_FIELD_PREFIX)) { // omit internal polyfields
         dynamicFieldProperties.add(dynamicField.getPrototype().getNamedPropertyValues(params.getBool("showDefaults", false)));
       }
     }
-    topLevel.add(DYNAMIC_FIELDS, dynamicFieldProperties);
-    topLevel.add(COPY_FIELDS, getCopyFieldProperties(false, null, null));
-    return topLevel;
+    return dynamicFieldProperties;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9313a630/solr/core/src/test/org/apache/solr/rest/schema/TestFieldCollectionResource.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/rest/schema/TestFieldCollectionResource.java b/solr/core/src/test/org/apache/solr/rest/schema/TestFieldCollectionResource.java
index dd55415..6fdd298 100644
--- a/solr/core/src/test/org/apache/solr/rest/schema/TestFieldCollectionResource.java
+++ b/solr/core/src/test/org/apache/solr/rest/schema/TestFieldCollectionResource.java
@@ -15,11 +15,9 @@
  * limitations under the License.
  */
 package org.apache.solr.rest.schema;
-import com.carrotsearch.randomizedtesting.annotations.Seed;
 import org.apache.solr.rest.SolrRestletTestBase;
 import org.junit.Test;
 
-import java.io.IOException;
 
 public class TestFieldCollectionResource extends SolrRestletTestBase {
   @Test
@@ -39,4 +37,20 @@ public class TestFieldCollectionResource extends SolrRestletTestBase {
              "/fields/[2]/name=='_version_'");
   }
 
+
+  @Test
+  public void testJsonGetAllFieldsIncludeDynamic() throws Exception {
+    assertJQ("/schema/fields?indent=on&includeDynamic=true",
+             "/fields/[0]/name=='HTMLstandardtok'",
+             "/fields/[1]/name=='HTMLwhitetok'",
+             "/fields/[2]/name=='_version_'",
+             "/fields/[98]/name=='*_d'",
+             "/fields/[97]/name=='*_f'",
+             "/fields/[96]/name=='*_b'",
+             "/fields/[95]/name=='*_t'",
+             "/fields/[94]/name=='*_l'"
+
+    );
+  }
+
 }