lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsmi...@apache.org
Subject [07/50] [abbrv] lucene-solr:solr-5750: SOLR-8992: Restore Schema API GET method functionality removed in 6.0
Date Wed, 27 Apr 2016 18:21:51 GMT
SOLR-8992: Restore Schema API GET method functionality removed in 6.0


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

Branch: refs/heads/solr-5750
Commit: e8cc19eb885c46d25b56fdd681825712516050c9
Parents: 81446cf
Author: Noble Paul <noble@apache.org>
Authored: Thu Apr 21 20:38:20 2016 +0530
Committer: Noble Paul <noble@apache.org>
Committed: Thu Apr 21 20:38:20 2016 +0530

----------------------------------------------------------------------
 solr/CHANGES.txt                                |   2 +
 .../org/apache/solr/handler/SchemaHandler.java  |   2 +-
 .../apache/solr/response/SchemaXmlWriter.java   |  27 ++-
 .../org/apache/solr/schema/IndexSchema.java     | 177 ++++++++++++++-----
 .../schema/TestCopyFieldCollectionResource.java |  34 ++++
 .../TestDynamicFieldCollectionResource.java     |  24 +++
 .../schema/TestFieldCollectionResource.java     |  33 ++++
 7 files changed, 239 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e8cc19eb/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 31ae74c..9c8d03b 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -148,6 +148,8 @@ Bug Fixes
 
 * SOLR-8971: Preserve root cause when wrapping exceptions (hossman)
 
+* SOLR-8992: Restore Schema API GET method functionality removed in 6.0 (noble, Steve Rowe)
+
 Optimizations
 ----------------------
 * SOLR-8722: Don't force a full ZkStateReader refresh on every Overseer operation.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e8cc19eb/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java b/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java
index da24c25..4da557d 100644
--- a/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java
@@ -185,7 +185,7 @@ public class SchemaHandler extends RequestHandlerBase implements SolrCoreAware,
           if (parts.get(0).isEmpty()) parts.remove(0);
           if (parts.size() > 1 && level2.containsKey(parts.get(1))) {
             String realName = level2.get(parts.get(1));
-            SimpleOrderedMap<Object> propertyValues = req.getSchema().getNamedPropertyValues(req.getParams());
+            Map propertyValues = req.getSchema().getNamedPropertyValues(realName, req.getParams());
             Object o = propertyValues.get(realName);
             if(parts.size()> 2) {
               String name = parts.get(2);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e8cc19eb/solr/core/src/java/org/apache/solr/response/SchemaXmlWriter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/response/SchemaXmlWriter.java b/solr/core/src/java/org/apache/solr/response/SchemaXmlWriter.java
index 4ed4d8f..a38fe36 100644
--- a/solr/core/src/java/org/apache/solr/response/SchemaXmlWriter.java
+++ b/solr/core/src/java/org/apache/solr/response/SchemaXmlWriter.java
@@ -78,8 +78,8 @@ public class SchemaXmlWriter extends TextResponseWriter {
       writer.write(MANAGED_SCHEMA_DO_NOT_EDIT_WARNING);
     }
 
-    @SuppressWarnings("unchecked") SimpleOrderedMap<Object> schemaProperties
-        = (SimpleOrderedMap<Object>)rsp.getValues().get(IndexSchema.SCHEMA);
+    @SuppressWarnings("unchecked") Map<String,Object> schemaProperties
+        = (Map<String , Object>)rsp.getValues().get(IndexSchema.SCHEMA);
 
     openStartTag(IndexSchema.SCHEMA);
     writeAttr(IndexSchema.NAME, schemaProperties.get(IndexSchema.NAME).toString());
@@ -87,34 +87,33 @@ public class SchemaXmlWriter extends TextResponseWriter {
     closeStartTag(false);
     incLevel();
 
-    for (int schemaPropNum = 0 ; schemaPropNum < schemaProperties.size() ; ++schemaPropNum)
{
-      String schemaPropName = schemaProperties.getName(schemaPropNum);
+    for (Map.Entry<String, Object> entry : schemaProperties.entrySet()) {
+      String schemaPropName = entry.getKey();
+      Object val = entry.getValue();
       if (schemaPropName.equals(IndexSchema.NAME) || schemaPropName.equals(IndexSchema.VERSION))
{
         continue;
       }
       if (schemaPropName.equals(IndexSchema.UNIQUE_KEY)) {
         openStartTag(IndexSchema.UNIQUE_KEY);
         closeStartTag(false);
-        writer.write(schemaProperties.getVal(schemaPropNum).toString());
+        writer.write(val.toString());
         endTag(IndexSchema.UNIQUE_KEY, false);
       } else if (schemaPropName.equals(IndexSchema.DEFAULT_SEARCH_FIELD)) {
         openStartTag(IndexSchema.DEFAULT_SEARCH_FIELD);
         closeStartTag(false);
-        writer.write(schemaProperties.getVal(schemaPropNum).toString());
+        writer.write(val.toString());
         endTag(IndexSchema.DEFAULT_SEARCH_FIELD, false);
       } else if (schemaPropName.equals(IndexSchema.SOLR_QUERY_PARSER)) {
         openStartTag(IndexSchema.SOLR_QUERY_PARSER);
-        @SuppressWarnings("unchecked") SimpleOrderedMap<Object> solrQueryParserProperties
-            = (SimpleOrderedMap<Object>)schemaProperties.getVal(schemaPropNum);
-        writeAttr(IndexSchema.DEFAULT_OPERATOR, solrQueryParserProperties.get(IndexSchema.DEFAULT_OPERATOR).toString());
+        writeAttr(IndexSchema.DEFAULT_OPERATOR, ((Map<String ,Object>) val).get(IndexSchema.DEFAULT_OPERATOR).toString());
         closeStartTag(true);
       } else if (schemaPropName.equals(IndexSchema.SIMILARITY)) {
-        writeSimilarity((SimpleOrderedMap<Object>) schemaProperties.getVal(schemaPropNum));
+        writeSimilarity((SimpleOrderedMap<Object>) val);
       } else if (schemaPropName.equals(IndexSchema.FIELD_TYPES)) {
-        writeFieldTypes((List<SimpleOrderedMap<Object>>)schemaProperties.getVal(schemaPropNum));
+        writeFieldTypes((List<SimpleOrderedMap<Object>>) val);
       } else if (schemaPropName.equals(IndexSchema.FIELDS)) {
         @SuppressWarnings("unchecked") List<SimpleOrderedMap<Object>> fieldPropertiesList
-            = (List<SimpleOrderedMap<Object>>)schemaProperties.getVal(schemaPropNum);
+            = (List<SimpleOrderedMap<Object>>) val;
         for (SimpleOrderedMap<Object> fieldProperties : fieldPropertiesList) {
           openStartTag(IndexSchema.FIELD);
           for (int fieldPropNum = 0 ; fieldPropNum < fieldProperties.size() ; ++fieldPropNum)
{
@@ -124,7 +123,7 @@ public class SchemaXmlWriter extends TextResponseWriter {
         }
       } else if (schemaPropName.equals(IndexSchema.DYNAMIC_FIELDS)) {
         @SuppressWarnings("unchecked") List<SimpleOrderedMap<Object>> dynamicFieldPropertiesList

-            = (List<SimpleOrderedMap<Object>>)schemaProperties.getVal(schemaPropNum);
+            = (List<SimpleOrderedMap<Object>>) val;
         for (SimpleOrderedMap<Object> dynamicFieldProperties : dynamicFieldPropertiesList)
{
           openStartTag(IndexSchema.DYNAMIC_FIELD);
           for (int dynamicFieldPropNum = 0 ; dynamicFieldPropNum < dynamicFieldProperties.size()
; ++dynamicFieldPropNum) {
@@ -135,7 +134,7 @@ public class SchemaXmlWriter extends TextResponseWriter {
         }
       } else if (schemaPropName.equals(IndexSchema.COPY_FIELDS)) {
         @SuppressWarnings("unchecked") List<SimpleOrderedMap<Object>> copyFieldPropertiesList
-            = (List<SimpleOrderedMap<Object>>)schemaProperties.getVal(schemaPropNum);
+            = (List<SimpleOrderedMap<Object>>) val;
         for (SimpleOrderedMap<Object> copyFieldProperties : copyFieldPropertiesList)
{
           openStartTag(IndexSchema.COPY_FIELD);
           for (int copyFieldPropNum = 0 ; copyFieldPropNum < copyFieldProperties.size()
; ++ copyFieldPropNum) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e8cc19eb/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 7f7bd73..f71db0a 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -20,11 +20,15 @@ import java.io.IOException;
 import java.io.Writer;
 import java.lang.invoke.MethodHandles;
 import java.util.*;
+import java.util.function.Function;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpressionException;
 
+import com.google.common.base.Functions;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.DelegatingAnalyzerWrapper;
 import org.apache.lucene.index.DocValuesType;
@@ -32,19 +36,21 @@ import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.IndexOptions;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexableField;
-import org.apache.lucene.index.IndexableField;
 import org.apache.lucene.index.MultiFields;
 import org.apache.lucene.search.similarities.Similarity;
 import org.apache.lucene.uninverting.UninvertingReader;
 import org.apache.lucene.util.Version;
 import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.SolrException;
+import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.MapSolrParams;
 import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.Pair;
 import org.apache.solr.common.util.SimpleOrderedMap;
 import org.apache.solr.core.Config;
+import org.apache.solr.core.MapSerializable;
 import org.apache.solr.core.SolrConfig;
 import org.apache.solr.core.SolrResourceLoader;
 import org.apache.solr.request.LocalSolrQueryRequest;
@@ -63,6 +69,7 @@ import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.xml.sax.InputSource;
 
+import static java.util.Arrays.asList;
 import static java.util.Collections.singletonList;
 import static java.util.Collections.singletonMap;
 
@@ -780,7 +787,7 @@ public class IndexSchema {
    * @param fields The sequence of {@link org.apache.solr.schema.SchemaField}
    */
   public void registerDynamicFields(SchemaField... fields) {
-    List<DynamicField> dynFields = new ArrayList<>(Arrays.asList(dynamicFields));
+    List<DynamicField> dynFields = new ArrayList<>(asList(dynamicFields));
     for (SchemaField field : fields) {
       if (isDuplicateDynField(dynFields, field)) {
         log.debug("dynamic field already exists: dynamic field: [" + field.getName() + "]");
@@ -1352,58 +1359,138 @@ public class IndexSchema {
   /**
    * Get a map of property name -&gt; value for the whole schema.
    */
-  public SimpleOrderedMap<Object> getNamedPropertyValues() {
-    return getNamedPropertyValues(new MapSolrParams(Collections.EMPTY_MAP));
+  public Map getNamedPropertyValues() {
+    return getNamedPropertyValues(null, new MapSolrParams(Collections.EMPTY_MAP));
+  }
+
+  static class SchemaProps implements MapSerializable {
+    private static final String SOURCE_FIELD_LIST = IndexSchema.SOURCE + "." + CommonParams.FL;
+    private static final String DESTINATION_FIELD_LIST = IndexSchema.DESTINATION + "." +
CommonParams.FL;
+    private final String name;
+    private final SolrParams params;
+    private final IndexSchema schema;
+    boolean showDefaults, includeDynamic;
+    Set<String> requestedFields;
+    private Set<String> requestedSourceFields;
+    private Set<String> requestedDestinationFields;
+
+
+    enum Handler {
+      NAME(IndexSchema.NAME, sp -> sp.schema.getSchemaName()),
+      VERSION(IndexSchema.VERSION, sp -> sp.schema.getVersion()),
+      UNIQUE_KEY(IndexSchema.UNIQUE_KEY, sp -> sp.schema.uniqueKeyFieldName),
+      DEFAULT_SEARCH_FIELD(IndexSchema.DEFAULT_SEARCH_FIELD, sp -> sp.schema.defaultSearchFieldName),
+      SOLR_QUERY_PARSER(IndexSchema.SOLR_QUERY_PARSER, sp -> sp.schema.isExplicitQueryParserDefaultOperator
?
+          singletonMap(DEFAULT_OPERATOR, sp.schema.queryParserDefaultOperator) :
+          null),
+      SIMILARITY(IndexSchema.SIMILARITY, sp -> sp.schema.isExplicitSimilarity ?
+          sp.schema.similarityFactory.getNamedPropertyValues() :
+          null),
+      FIELD_TYPES(IndexSchema.FIELD_TYPES, sp -> new TreeMap<>(sp.schema.fieldTypes)
+          .values().stream()
+          .map(it -> it.getNamedPropertyValues(sp.showDefaults))
+          .collect(Collectors.toList())),
+
+      DYNAMIC_FIELDS(IndexSchema.DYNAMIC_FIELDS, sp -> Stream.of(sp.schema.dynamicFields)
+          .filter(it -> !it.getRegex().startsWith(INTERNAL_POLY_FIELD_PREFIX))
+          .filter(it -> sp.requestedFields == null || sp.requestedFields.contains(it.getPrototype().getName()))
+          .map(it -> sp.getProperties(it.getPrototype()))
+          .collect(Collectors.toList())),
+      FIELDS(IndexSchema.FIELDS, sp -> {
+        List<SimpleOrderedMap> result = (sp.requestedFields != null ? sp.requestedFields
: new TreeSet<>(sp.schema.fields.keySet()))
+            .stream()
+            .map(sp.schema::getFieldOrNull)
+            .filter(it -> it != null)
+            .filter(it -> sp.includeDynamic || !sp.schema.isDynamicField(it.name))
+            .map(sp::getProperties)
+            .collect(Collectors.toList());
+        if (sp.includeDynamic && sp.requestedFields == null) {
+          result.addAll((Collection) Handler.DYNAMIC_FIELDS.fun.apply(sp));
+        }
+        return result;
+      }),
 
-  }
-  public SimpleOrderedMap<Object> getNamedPropertyValues(SolrParams params) {
-    SimpleOrderedMap<Object> topLevel = new SimpleOrderedMap<>();
-    topLevel.add(NAME, getSchemaName());
-    topLevel.add(VERSION, getVersion());
-    if (null != uniqueKeyFieldName) {
-      topLevel.add(UNIQUE_KEY, uniqueKeyFieldName);
-    }
-    if (null != defaultSearchFieldName) {
-      topLevel.add(DEFAULT_SEARCH_FIELD, defaultSearchFieldName);
-    }
-    if (isExplicitQueryParserDefaultOperator) {
-      SimpleOrderedMap<Object> solrQueryParserProperties = new SimpleOrderedMap<>();
-      solrQueryParserProperties.add(DEFAULT_OPERATOR, queryParserDefaultOperator);
-      topLevel.add(SOLR_QUERY_PARSER, solrQueryParserProperties);
-    }
-    if (isExplicitSimilarity) {
-      topLevel.add(SIMILARITY, similarityFactory.getNamedPropertyValues());
+
+      COPY_FIELDS(IndexSchema.COPY_FIELDS, sp -> sp.schema.getCopyFieldProperties(false,
+          sp.requestedSourceFields, sp.requestedDestinationFields));
+
+      final Function<SchemaProps, Object> fun;
+      final String name;
+      Handler(String name, Function<SchemaProps, Object> fun) {
+        this.fun = fun;
+        this.name = name;
+      }
     }
-    List<SimpleOrderedMap<Object>> fieldTypeProperties = new ArrayList<>();
-    SortedMap<String,FieldType> sortedFieldTypes = new TreeMap<>(fieldTypes);
-    for (FieldType fieldType : sortedFieldTypes.values()) {
-      fieldTypeProperties.add(fieldType.getNamedPropertyValues(params.getBool("showDefaults",
false)));
+
+    SchemaProps(String name, SolrParams params, IndexSchema schema) {
+      this.name = name;
+      this.params = params;
+      this.schema = schema;
+      showDefaults = params.getBool("showDefaults", false);
+      includeDynamic = params.getBool("includeDynamic", false);
+
+      String sourceFieldListParam = params.get(SOURCE_FIELD_LIST);
+      if (null != sourceFieldListParam) {
+        String[] fields = sourceFieldListParam.trim().split("[,\\s]+");
+        if (fields.length > 0) {
+          requestedSourceFields = new HashSet<>(Arrays.asList(fields));
+          requestedSourceFields.remove(""); // Remove empty values, if any
+        }
+      }
+      String destinationFieldListParam = params.get(DESTINATION_FIELD_LIST);
+      if (null != destinationFieldListParam) {
+        String[] fields = destinationFieldListParam.trim().split("[,\\s]+");
+        if (fields.length > 0) {
+          requestedDestinationFields = new HashSet<>(Arrays.asList(fields));
+          requestedDestinationFields.remove(""); // Remove empty values, if any
+        }
+      }
+
+      String flParam = params.get(CommonParams.FL);
+      if (null != flParam) {
+        String[] fields = flParam.trim().split("[,\\s]+");
+        if (fields.length > 0)
+          requestedFields = new LinkedHashSet<>(Stream.of(fields)
+              .filter(it -> !it.trim().isEmpty())
+              .collect(Collectors.toList()));
+
+      }
+
     }
-    topLevel.add(FIELD_TYPES, fieldTypeProperties);  
-    List<SimpleOrderedMap<Object>> fieldProperties = new ArrayList<>();
-    SortedSet<String> fieldNames = new TreeSet<>(fields.keySet());
-    for (String fieldName : fieldNames) {
-      fieldProperties.add(fields.get(fieldName).getNamedPropertyValues(params.getBool("showDefaults",
false)));
+
+
+    SimpleOrderedMap getProperties(SchemaField sf) {
+      SimpleOrderedMap<Object> result = sf.getNamedPropertyValues(showDefaults);
+      if (schema.isDynamicField(sf.name)) {
+        String dynamicBase = schema.getDynamicPattern(sf.getName());
+        // Add dynamicBase property if it's different from the field name.
+        if (!sf.getName().equals(dynamicBase)) {
+          result.add("dynamicBase", dynamicBase);
+        }
+      }
+      return result;
     }
-    if (params.getBool("includeDynamic", false)) {
-      fieldProperties.addAll(getDynamicFields(params));
+
+
+    @Override
+    public Map<String, Object> toMap() {
+      Map<String, Object> topLevel = new LinkedHashMap<>();
+      Stream.of(Handler.values())
+          .filter(it -> name == null || it.name.equals(name))
+          .forEach(it -> {
+            Object val = it.fun.apply(this);
+            if (val != null) topLevel.put(it.name, val);
+          });
+      return topLevel;
     }
-    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 (DynamicField dynamicField : dynamicFields) {
-      if ( ! dynamicField.getRegex().startsWith(INTERNAL_POLY_FIELD_PREFIX)) { // omit internal
polyfields
-        dynamicFieldProperties.add(dynamicField.getPrototype().getNamedPropertyValues(params.getBool("showDefaults",
false)));
-      }
-    }
-    return dynamicFieldProperties;
+  public Map<String, Object> getNamedPropertyValues(String name, SolrParams params)
{
+    return new SchemaProps(name, params, this).toMap();
+
   }
 
+
   /**
    * Returns a list of copyField directives, with optional details and optionally restricting
to those
    * directives that contain the requested source and/or destination field names.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e8cc19eb/solr/core/src/test/org/apache/solr/rest/schema/TestCopyFieldCollectionResource.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/rest/schema/TestCopyFieldCollectionResource.java
b/solr/core/src/test/org/apache/solr/rest/schema/TestCopyFieldCollectionResource.java
index c0f936d..7b39ab3 100644
--- a/solr/core/src/test/org/apache/solr/rest/schema/TestCopyFieldCollectionResource.java
+++ b/solr/core/src/test/org/apache/solr/rest/schema/TestCopyFieldCollectionResource.java
@@ -100,4 +100,38 @@ public class TestCopyFieldCollectionResource extends SolrRestletTestBase
{
 
   }
 
+  @Test
+  public void testRestrictSource() throws Exception {
+    assertQ("/schema/copyfields/?indent=on&wt=xml&source.fl=title,*_i,*_src_sub_i,src_sub_no_ast_i",
+        "count(/response/arr[@name='copyFields']/lst) = 16", // 4 + 4 + 4 + 4
+        "count(/response/arr[@name='copyFields']/lst/str[@name='source'][.='title']) = 4",
+        "count(/response/arr[@name='copyFields']/lst/str[@name='source'][.='*_i']) = 4",
+        "count(/response/arr[@name='copyFields']/lst/str[@name='source'][.='*_src_sub_i'])
= 4",
+        "count(/response/arr[@name='copyFields']/lst/str[@name='source'][.='src_sub_no_ast_i'])
= 4");
+  }
+
+  @Test
+  public void testRestrictDest() throws Exception {
+    assertQ("/schema/copyfields/?indent=on&wt=xml&dest.fl=title,*_s,*_dest_sub_s,dest_sub_no_ast_s",
+        "count(/response/arr[@name='copyFields']/lst) = 16", // 3 + 4 + 4 + 5
+        "count(/response/arr[@name='copyFields']/lst/str[@name='dest'][.='title']) = 3",
+        "count(/response/arr[@name='copyFields']/lst/str[@name='dest'][.='*_s']) = 4",
+        "count(/response/arr[@name='copyFields']/lst/str[@name='dest'][.='*_dest_sub_s'])
= 4",
+        "count(/response/arr[@name='copyFields']/lst/str[@name='dest'][.='dest_sub_no_ast_s'])
= 5");
+  }
+
+  @Test
+  public void testRestrictSourceAndDest() throws Exception {
+    assertQ("/schema/copyfields/?indent=on&wt=xml&source.fl=title,*_i&dest.fl=title,dest_sub_no_ast_s",
+        "count(/response/arr[@name='copyFields']/lst) = 3",
+
+        "/response/arr[@name='copyFields']/lst[    str[@name='source'][.='title']"
+            + "                                      and str[@name='dest'][.='dest_sub_no_ast_s']]",
+
+        "/response/arr[@name='copyFields']/lst[    str[@name='source'][.='*_i']"
+            + "                                      and str[@name='dest'][.='title']]",
+
+        "/response/arr[@name='copyFields']/lst[    str[@name='source'][.='*_i']"
+            + "                                      and str[@name='dest'][.='dest_sub_no_ast_s']]");
+  }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e8cc19eb/solr/core/src/test/org/apache/solr/rest/schema/TestDynamicFieldCollectionResource.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/rest/schema/TestDynamicFieldCollectionResource.java
b/solr/core/src/test/org/apache/solr/rest/schema/TestDynamicFieldCollectionResource.java
index 032bbad..6734ca2 100644
--- a/solr/core/src/test/org/apache/solr/rest/schema/TestDynamicFieldCollectionResource.java
+++ b/solr/core/src/test/org/apache/solr/rest/schema/TestDynamicFieldCollectionResource.java
@@ -30,10 +30,34 @@ public class TestDynamicFieldCollectionResource extends SolrRestletTestBase
{
   }
 
   @Test
+  public void testGetTwoDynamicFields() throws IOException {
+    assertQ("/schema/dynamicfields?indent=on&wt=xml&fl=*_i,*_s",
+            "count(/response/arr[@name='dynamicFields']/lst/str[@name='name']) = 2",
+            "(/response/arr[@name='dynamicFields']/lst/str[@name='name'])[1] = '*_i'",
+            "(/response/arr[@name='dynamicFields']/lst/str[@name='name'])[2] = '*_s'");
+  }
+
+  @Test
+  public void testNotFoundDynamicFields() throws IOException {
+    assertQ("/schema/dynamicfields?indent=on&wt=xml&fl=*_not_in_there,this_one_isnt_either_*",
+            "count(/response/arr[@name='dynamicFields']) = 1",
+            "count(/response/arr[@name='dynamicfields']/lst/str[@name='name']) = 0");
+  }
+
+  @Test
   public void testJsonGetAllDynamicFields() throws Exception {
     assertJQ("/schema/dynamicfields?indent=on",
              "/dynamicFields/[0]/name=='*_coordinate'",
              "/dynamicFields/[1]/name=='ignored_*'",
              "/dynamicFields/[2]/name=='*_mfacet'");
   }
+
+  @Test
+  public void testJsonGetTwoDynamicFields() throws Exception {
+    assertJQ("/schema/dynamicfields?indent=on&fl=*_i,*_s&wt=xml", // assertJQ will
fix the wt param to be json
+             "/dynamicFields/[0]/name=='*_i'",
+             "/dynamicFields/[1]/name=='*_s'");
+  }
+
+
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e8cc19eb/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 6fdd298..f3de92b 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,6 +15,8 @@
  * limitations under the License.
  */
 package org.apache.solr.rest.schema;
+import java.io.IOException;
+
 import org.apache.solr.rest.SolrRestletTestBase;
 import org.junit.Test;
 
@@ -37,6 +39,37 @@ public class TestFieldCollectionResource extends SolrRestletTestBase {
              "/fields/[2]/name=='_version_'");
   }
 
+  @Test
+  public void testGetThreeFieldsDontIncludeDynamic() throws IOException {
+    //
+    assertQ("/schema/fields?indent=on&wt=xml&fl=id,_version_,price_i",
+        "count(/response/arr[@name='fields']/lst/str[@name='name']) = 2",
+        "(/response/arr[@name='fields']/lst/str[@name='name'])[1] = 'id'",
+        "(/response/arr[@name='fields']/lst/str[@name='name'])[2] = '_version_'");
+  }
+
+  @Test
+  public void testGetThreeFieldsIncludeDynamic() throws IOException {
+    assertQ("/schema/fields?indent=on&wt=xml&fl=id,_version_,price_i&includeDynamic=on",
+
+        "count(/response/arr[@name='fields']/lst/str[@name='name']) = 3",
+
+        "(/response/arr[@name='fields']/lst/str[@name='name'])[1] = 'id'",
+
+        "(/response/arr[@name='fields']/lst/str[@name='name'])[2] = '_version_'",
+
+        "(/response/arr[@name='fields']/lst/str[@name='name'])[3] = 'price_i'",
+
+        "/response/arr[@name='fields']/lst[    str[@name='name']='price_i'    "
+            +"                                  and str[@name='dynamicBase']='*_i']");
+  }
+  @Test
+  public void testNotFoundFields() throws IOException {
+    assertQ("/schema/fields?indent=on&wt=xml&fl=not_in_there,this_one_either",
+        "count(/response/arr[@name='fields']) = 1",
+        "count(/response/arr[@name='fields']/lst/str[@name='name']) = 0");
+  }
+
 
   @Test
   public void testJsonGetAllFieldsIncludeDynamic() throws Exception {


Mime
View raw message