This commit is contained in:
Karl Wright 2016-04-15 07:11:36 -04:00
commit 0e06e42ffa
3 changed files with 29 additions and 6 deletions

View File

@ -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 * 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) 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 ================== ================== 6.0.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release

View File

@ -1385,16 +1385,23 @@ public class IndexSchema {
for (String fieldName : fieldNames) { for (String fieldName : fieldNames) {
fieldProperties.add(fields.get(fieldName).getNamedPropertyValues(params.getBool("showDefaults", false))); 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(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<>(); 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 if ( ! dynamicField.getRegex().startsWith(INTERNAL_POLY_FIELD_PREFIX)) { // omit internal polyfields
dynamicFieldProperties.add(dynamicField.getPrototype().getNamedPropertyValues(params.getBool("showDefaults", false))); dynamicFieldProperties.add(dynamicField.getPrototype().getNamedPropertyValues(params.getBool("showDefaults", false)));
} }
} }
topLevel.add(DYNAMIC_FIELDS, dynamicFieldProperties); return dynamicFieldProperties;
topLevel.add(COPY_FIELDS, getCopyFieldProperties(false, null, null));
return topLevel;
} }
/** /**

View File

@ -15,11 +15,9 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.solr.rest.schema; package org.apache.solr.rest.schema;
import com.carrotsearch.randomizedtesting.annotations.Seed;
import org.apache.solr.rest.SolrRestletTestBase; import org.apache.solr.rest.SolrRestletTestBase;
import org.junit.Test; import org.junit.Test;
import java.io.IOException;
public class TestFieldCollectionResource extends SolrRestletTestBase { public class TestFieldCollectionResource extends SolrRestletTestBase {
@Test @Test
@ -39,4 +37,20 @@ public class TestFieldCollectionResource extends SolrRestletTestBase {
"/fields/[2]/name=='_version_'"); "/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'"
);
}
} }