You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/08/15 22:22:53 UTC

[lucene-solr] branch reference_impl_dev updated (79e581e -> 477a450)

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

markrmiller pushed a change to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.


 discard 79e581e  @549 Open your eyes, let's begin.
     new 477a450  @550 Open your eyes, let's begin.

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (79e581e)
            \
             N -- N -- N   refs/heads/reference_impl_dev (477a450)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:


[lucene-solr] 01/01: @550 Open your eyes, let's begin.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 477a450e73523ecff2116b0ff23dac906939d089
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Sat Aug 15 17:22:18 2020 -0500

    @550 Open your eyes, let's begin.
---
 .../solr/rest/schema/FieldTypeXmlAdapter.java      |  1 -
 .../apache/solr/schema/FieldTypePluginLoader.java  | 77 +++++++++++++++++-----
 2 files changed, 61 insertions(+), 17 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/rest/schema/FieldTypeXmlAdapter.java b/solr/core/src/java/org/apache/solr/rest/schema/FieldTypeXmlAdapter.java
index ed9bf4f..fffa5a2 100644
--- a/solr/core/src/java/org/apache/solr/rest/schema/FieldTypeXmlAdapter.java
+++ b/solr/core/src/java/org/apache/solr/rest/schema/FieldTypeXmlAdapter.java
@@ -29,7 +29,6 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
-import javax.xml.XMLConstants;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
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 3bb9483..04efa40 100644
--- a/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java
+++ b/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java
@@ -38,6 +38,7 @@ import org.w3c.dom.NodeList;
 import static org.apache.solr.common.params.CommonParams.NAME;
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
 import javax.xml.xpath.XPathExpressionException;
 import java.lang.invoke.MethodHandles;
 import java.util.ArrayList;
@@ -53,6 +54,55 @@ public final class FieldTypePluginLoader
 
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
+  private static XPathExpression analyzerQueryExp;
+  private static XPathExpression analyzerMultiTermExp;
+
+  private static XPathExpression analyzerIndexExp;
+  private static XPathExpression similarityExp;
+  private static XPathExpression charFilterExp;
+  private static XPathExpression tokenizerExp;
+  private static XPathExpression filterExp;
+
+  static {
+    try {
+      analyzerQueryExp = IndexSchema.getXpath().compile("./analyzer[@type='query']");
+    } catch (XPathExpressionException e) {
+      log.error("", e);
+    }
+    try {
+      analyzerMultiTermExp = IndexSchema.getXpath().compile("./analyzer[@type='multiterm']");
+    } catch (XPathExpressionException e) {
+      log.error("", e);
+    }
+
+    try {
+      analyzerIndexExp = IndexSchema.getXpath().compile("./analyzer[not(@type)] | ./analyzer[@type='index']");
+    } catch (XPathExpressionException e) {
+      log.error("", e);
+    }
+    try {
+      similarityExp = IndexSchema.getXpath().compile("./similarity");
+    } catch (XPathExpressionException e) {
+      log.error("", e);
+    }
+
+
+    try {
+      charFilterExp = IndexSchema.getXpath().compile("./charFilter");
+    } catch (XPathExpressionException e) {
+      log.error("", e);
+    }
+    try {
+      tokenizerExp = IndexSchema.getXpath().compile("./tokenizer");
+    } catch (XPathExpressionException e) {
+      log.error("", e);
+    }
+    try {
+      filterExp = IndexSchema.getXpath().compile("./filter");
+    } catch (XPathExpressionException e) {
+      log.error("", e);
+    }
+  }
 
   /**
    * @param schema The schema that will be used to initialize the FieldTypes
@@ -83,23 +133,19 @@ public final class FieldTypePluginLoader
 
     FieldType ft = loader.newInstance(className, FieldType.class, "schema.");
     ft.setTypeName(name);
-    
-    String expression = "./analyzer[@type='query']";
-    Node anode = (Node)xpath.evaluate(expression, node, XPathConstants.NODE);
+
+    Node anode = (Node) analyzerQueryExp.evaluate(node, XPathConstants.NODE);
     Analyzer queryAnalyzer = readAnalyzer(anode);
 
-    expression = "./analyzer[@type='multiterm']";
-    anode = (Node)xpath.evaluate(expression, node, XPathConstants.NODE);
+    anode = (Node)analyzerMultiTermExp.evaluate(node, XPathConstants.NODE);
     Analyzer multiAnalyzer = readAnalyzer(anode);
 
     // An analyzer without a type specified, or with type="index"
-    expression = "./analyzer[not(@type)] | ./analyzer[@type='index']";
-    anode = (Node)xpath.evaluate(expression, node, XPathConstants.NODE);
+    anode = (Node)analyzerIndexExp.evaluate( node, XPathConstants.NODE);
     Analyzer analyzer = readAnalyzer(anode);
 
     // a custom similarity[Factory]
-    expression = "./similarity";
-    anode = (Node)xpath.evaluate(expression, node, XPathConstants.NODE);
+    anode = (Node)similarityExp.evaluate(node, XPathConstants.NODE);
     SimilarityFactory simFactory = IndexSchema.readSimilarity(loader, anode);
     if (null != simFactory) {
       ft.setSimilarity(simFactory);
@@ -196,16 +242,15 @@ public final class FieldTypePluginLoader
     if (node == null) return null;
     NamedNodeMap attrs = node.getAttributes();
     String analyzerName = DOMUtil.getAttr(attrs,"class");
-    XPath xpath = IndexSchema.getXpath();
 
     // check for all of these up front, so we can error if used in 
     // conjunction with an explicit analyzer class.
-    NodeList charFilterNodes = (NodeList)xpath.evaluate
-      ("./charFilter",  node, XPathConstants.NODESET);
-    NodeList tokenizerNodes = (NodeList)xpath.evaluate
-      ("./tokenizer", node, XPathConstants.NODESET);
-    NodeList tokenFilterNodes = (NodeList)xpath.evaluate
-      ("./filter", node, XPathConstants.NODESET);
+    NodeList charFilterNodes = (NodeList)charFilterExp.evaluate
+      (node, XPathConstants.NODESET);
+    NodeList tokenizerNodes = (NodeList)tokenizerExp.evaluate
+      (node, XPathConstants.NODESET);
+    NodeList tokenFilterNodes = (NodeList)filterExp.evaluate
+      (node, XPathConstants.NODESET);
       
     if (analyzerName != null) {