You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by is...@apache.org on 2020/12/05 04:37:30 UTC

[lucene-solr] 03/18: bug fix

This is an automated email from the ASF dual-hosted git repository.

ishan pushed a commit to branch jira/solr14827
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit a6f6330607318d200b6e4e574e9462b0c1aba6a6
Author: noblepaul <no...@gmail.com>
AuthorDate: Fri Sep 4 18:21:40 2020 +1000

    bug fix
---
 .../org/apache/solr/schema/FieldTypePluginLoader.java    |  8 ++++----
 .../src/java/org/apache/solr/schema/IndexSchema.java     | 16 +++++++++++-----
 .../src/java/org/apache/solr/util/DataConfigNode.java    |  3 +++
 3 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java b/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java
index b52809e..22625d7 100644
--- a/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java
+++ b/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java
@@ -79,7 +79,7 @@ public final class FieldTypePluginLoader
     FieldType ft = loader.newInstance(className, FieldType.class);
     ft.setTypeName(name);
     
-    String expression = "./analyzer[@type='query']";
+//    String expression = "./analyzer[@type='query']";
     ConfigNode anode = node.child(it -> "query".equals(it.attributes().get("type")) , "analyzer");
     Analyzer queryAnalyzer = readAnalyzer(anode);
 
@@ -88,15 +88,15 @@ public final class FieldTypePluginLoader
     Analyzer multiAnalyzer = readAnalyzer(anode);
 
     // An analyzer without a type specified, or with type="index"
-    expression = "./analyzer[not(@type)] | ./analyzer[@type='index']";
+//    expression = "./analyzer[not(@type)] | ./analyzer[@type='index']";
     anode = node.child(it ->
         (it.attributes().get("type") == null || "index".equals(it.attributes().get("type"))), "analyzer");
 //    anode = (Node)xpath.evaluate(expression, node, XPathConstants.NODE);
     Analyzer analyzer = readAnalyzer(anode);
 
     // a custom similarity[Factory]
-    expression = "./similarity";
-    anode = node.child(it -> "multiterm".equals(it.attributes().get("type")), "similarity") ;
+//    expression = "./similarity";
+    anode = node.child("similarity") ;
 
     SimilarityFactory simFactory = IndexSchema.readSimilarity(loader, anode);
     if (null != simFactory) {
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 4a0e4b0..8344fc6 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -170,7 +170,7 @@ public class IndexSchema {
    * directives that target them.
    */
   protected Map<SchemaField, Integer> copyFieldTargetCounts = new HashMap<>();
-//  static AtomicLong totalSchemaLoadTime = new AtomicLong();
+  static AtomicLong totalSchemaLoadTime = new AtomicLong();
 
 
   /**
@@ -183,9 +183,9 @@ public class IndexSchema {
 
     this.resourceName = Objects.requireNonNull(name);
     try {
-//      long start = System.currentTimeMillis();
+      long start = System.currentTimeMillis();
       readSchema(is);
-//      System.out.println("schema-load-time : "+ totalSchemaLoadTime.addAndGet (System.currentTimeMillis() - start));
+      System.out.println("schema-load-time : "+ totalSchemaLoadTime.addAndGet (System.currentTimeMillis() - start));
       loader.inform(loader);
     } catch (IOException e) {
       throw new RuntimeException(e);
@@ -513,8 +513,10 @@ public class IndexSchema {
 //      expression = getFieldTypeXPathExpressions();
 //      NodeList nodes = (NodeList) xpath.evaluate(expression, document, XPathConstants.NODESET);
 
-      typeLoader.load(solrClassLoader,
-          rootNode.children(null, FIELDTYPE_KEYS));
+      List<ConfigNode> fTypes = rootNode.children(null, FIELDTYPE_KEYS);
+      ConfigNode types = rootNode.child(TYPES);
+      if(types != null) fTypes.addAll(types.children(null, FIELDTYPE_KEYS));
+      typeLoader.load(solrClassLoader, fTypes);
 
       // load the fields
       Map<String,Boolean> explicitRequiredProp = loadFields(rootNode);
@@ -664,6 +666,10 @@ public class IndexSchema {
         + XPATH_OR + stepsToPath(SCHEMA, FIELDS, FIELD)
         + XPATH_OR + stepsToPath(SCHEMA, FIELDS, DYNAMIC_FIELD);*/
     List<ConfigNode> nodes = n.children(null,  FIELD_KEYS);
+    ConfigNode child = n.child(FIELDS);
+    if(child != null) {
+      nodes.addAll(child.children(null, FIELD_KEYS));
+    }
 
 //    NodeList nodes = (NodeList)xpath.evaluate(expression, document, XPathConstants.NODESET);
 
diff --git a/solr/core/src/java/org/apache/solr/util/DataConfigNode.java b/solr/core/src/java/org/apache/solr/util/DataConfigNode.java
index 2567667..d7bc679 100644
--- a/solr/core/src/java/org/apache/solr/util/DataConfigNode.java
+++ b/solr/core/src/java/org/apache/solr/util/DataConfigNode.java
@@ -29,6 +29,9 @@ import java.util.function.Predicate;
 import org.apache.solr.cluster.api.SimpleMap;
 import org.apache.solr.common.ConfigNode;
 
+/**
+ * ConfigNode impl that copies and maintains data internally
+ */
 public class DataConfigNode implements ConfigNode {
   final String name;
   final SimpleMap<String> attributes;