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 2020/09/04 08:22:25 UTC
[lucene-solr] 02/02: bug fix
This is an automated email from the ASF dual-hosted git repository.
noble pushed a commit to branch jira/solr14827
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit f130ca438102dd1d35de05e20cde6b76627eb845
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 b64beb5..618d91d 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 59d910a..7b13349 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -169,7 +169,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();
/**
@@ -182,9 +182,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);
@@ -512,8 +512,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);
@@ -663,6 +665,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;