You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sa...@apache.org on 2014/04/05 07:10:51 UTC
svn commit: r1584971 - in /lucene/dev/branches/branch_4x: ./ solr/
solr/core/ solr/core/src/java/org/apache/solr/rest/schema/analysis/
solr/core/src/test-files/solr/collection1/conf/
solr/core/src/test/org/apache/solr/rest/ solr/core/src/test/org/apach...
Author: sarowe
Date: Sat Apr 5 05:10:50 2014
New Revision: 1584971
URL: http://svn.apache.org/r1584971
Log:
SOLR-5655: Create a stopword filter factory that is (re)configurable, and capable of reporting its configuration, via REST API (merged trunk r1577540)
Added:
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/rest/schema/analysis/BaseManagedTokenFilterFactory.java
- copied unchanged from r1577540, lucene/dev/trunk/solr/core/src/java/org/apache/solr/rest/schema/analysis/BaseManagedTokenFilterFactory.java
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/rest/schema/analysis/ManagedStopFilterFactory.java
- copied unchanged from r1577540, lucene/dev/trunk/solr/core/src/java/org/apache/solr/rest/schema/analysis/ManagedStopFilterFactory.java
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/rest/schema/analysis/
- copied from r1577540, lucene/dev/trunk/solr/core/src/test/org/apache/solr/rest/schema/analysis/
lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/_schema_analysis_stopwords_english.json
- copied unchanged from r1577540, lucene/dev/trunk/solr/example/solr/collection1/conf/_schema_analysis_stopwords_english.json
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/solr/ (props changed)
lucene/dev/branches/branch_4x/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_4x/solr/core/ (props changed)
lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema-rest.xml
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/rest/SolrRestletTestBase.java
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/rest/schema/analysis/TestManagedStopFilterFactory.java
lucene/dev/branches/branch_4x/solr/example/ (props changed)
lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/schema.xml
lucene/dev/branches/branch_4x/solr/test-framework/ (props changed)
lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/BaseTestHarness.java
lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/RestTestHarness.java
Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1584971&r1=1584970&r2=1584971&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Sat Apr 5 05:10:50 2014
@@ -117,6 +117,10 @@ New Features
* SOLR-5653: Create a RestManager to provide REST API endpoints for
reconfigurable plugins. (Tim Potter, Steve Rowe)
+* SOLR-5655: Create a stopword filter factory that is (re)configurable,
+ and capable of reporting its configuration, via REST API.
+ (Tim Potter via Steve Rowe)
+
Bug Fixes
----------------------
Modified: lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema-rest.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema-rest.xml?rev=1584971&r1=1584970&r2=1584971&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema-rest.xml (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema-rest.xml Sat Apr 5 05:10:50 2014
@@ -456,6 +456,14 @@
<!-- A specialized field for geospatial search. If indexed, this fieldType must not be multivalued. -->
<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
+ <!-- Field type where stopwords are managed by the REST API -->
+ <fieldtype name="managed_en" class="solr.TextField">
+ <analyzer>
+ <tokenizer class="solr.StandardTokenizerFactory"/>
+ <filter class="solr.ManagedStopFilterFactory" managed="english" />
+ </analyzer>
+ </fieldtype>
+
</types>
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/rest/SolrRestletTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/rest/SolrRestletTestBase.java?rev=1584971&r1=1584970&r2=1584971&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/rest/SolrRestletTestBase.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/rest/SolrRestletTestBase.java Sat Apr 5 05:10:50 2014
@@ -25,8 +25,14 @@ import java.util.SortedMap;
import java.util.TreeMap;
/**
- * Base class for Solr Restlet-based tests. Creates test harness,
- * including "extra" servlets for all Solr Restlet Application subclasses.
+ * Base class for Solr Restlet-based tests. Creates jetty and test harness
+ * with solrconfig.xml and schema-rest.xml, including "extra" servlets for
+ * all Solr Restlet Application subclasses.
+ *
+ * Use RestTestBase instead if you need to specialize the solrconfig,
+ * the schema, or jetty/test harness creation; otherwise you'll get
+ * imbalanced SolrIndexSearcher closes/opens and a suite-level failure
+ * for a zombie thread.
*/
abstract public class SolrRestletTestBase extends RestTestBase {
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/rest/schema/analysis/TestManagedStopFilterFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/rest/schema/analysis/TestManagedStopFilterFactory.java?rev=1584971&r1=1577540&r2=1584971&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/rest/schema/analysis/TestManagedStopFilterFactory.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/rest/schema/analysis/TestManagedStopFilterFactory.java Sat Apr 5 05:10:50 2014
@@ -44,8 +44,7 @@ public class TestManagedStopFilterFactor
@Before
public void before() throws Exception {
- createTempDir();
- tmpSolrHome = new File(TEMP_DIR + File.separator + TestManagedStopFilterFactory.class.getSimpleName()
+ tmpSolrHome = new File(dataDir + File.separator + TestManagedStopFilterFactory.class.getSimpleName()
+ System.currentTimeMillis());
tmpConfDir = new File(tmpSolrHome, confDir);
FileUtils.copyDirectory(new File(TEST_HOME()), tmpSolrHome.getAbsoluteFile());
Modified: lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/schema.xml?rev=1584971&r1=1584970&r2=1584971&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/schema.xml (original)
+++ lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/schema.xml Sat Apr 5 05:10:50 2014
@@ -449,6 +449,14 @@
</analyzer>
</fieldType>
+ <!-- A text type for English text where stopwords and synonyms are managed using the REST API -->
+ <fieldType name="managed_en" class="solr.TextField" positionIncrementGap="100">
+ <analyzer>
+ <tokenizer class="solr.StandardTokenizerFactory"/>
+ <filter class="solr.ManagedStopFilterFactory" managed="english" />
+ </analyzer>
+ </fieldType>
+
<!-- A general text field that has reasonable, generic
cross-language defaults: it tokenizes with StandardTokenizer,
removes stop words from case-insensitive "stopwords.txt"
Modified: lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/BaseTestHarness.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/BaseTestHarness.java?rev=1584971&r1=1584970&r2=1584971&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/BaseTestHarness.java (original)
+++ lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/BaseTestHarness.java Sat Apr 5 05:10:50 2014
@@ -21,6 +21,7 @@ import org.apache.solr.common.util.XML;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
+import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
@@ -99,6 +100,24 @@ abstract public class BaseTestHarness {
return null;
}
+ public static Object evaluateXPath(String xml, String xpath, QName returnType)
+ throws XPathExpressionException, SAXException {
+ if (null == xpath) return null;
+
+ Document document = null;
+ try {
+ document = getXmlDocumentBuilder().parse(new ByteArrayInputStream
+ (xml.getBytes("UTF-8")));
+ } catch (UnsupportedEncodingException e1) {
+ throw new RuntimeException("Totally weird UTF-8 exception", e1);
+ } catch (IOException e2) {
+ throw new RuntimeException("Totally weird io exception", e2);
+ }
+
+ xpath = xpath.trim();
+ return getXpath().evaluate(xpath.trim(), document, returnType);
+ }
+
/**
* A helper that creates an xml <doc> containing all of the
* fields and values specified
Modified: lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/RestTestHarness.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/RestTestHarness.java?rev=1584971&r1=1584970&r2=1584971&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/RestTestHarness.java (original)
+++ lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/util/RestTestHarness.java Sat Apr 5 05:10:50 2014
@@ -20,6 +20,7 @@ import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
+import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import org.apache.http.HttpEntity;
@@ -150,15 +151,22 @@ public class RestTestHarness extends Bas
}
}
-
+
+ /**
+ * Reloads the first core listed in the response to the core admin handler STATUS command
+ */
@Override
public void reload() throws Exception {
- String xml = checkResponseStatus("/admin/cores?action=RELOAD", "0");
+ String coreName = (String)evaluateXPath
+ (query("/admin/cores?action=STATUS"),
+ "//lst[@name='status']/lst[1]/str[@name='name']",
+ XPathConstants.STRING);
+ String xml = checkResponseStatus("/admin/cores?action=RELOAD&core=" + coreName, "0");
if (null != xml) {
throw new RuntimeException("RELOAD failed:\n" + xml);
}
}
-
+
/**
* Processes an "update" (add, commit or optimize) and
* returns the response as a String.