You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by da...@apache.org on 2017/12/27 15:04:26 UTC
[33/54] [abbrv] lucene-solr:jira/solr-11702: LUCENE-5803: Add a Solr
test that we reuse analysis components across fields for the same field type
LUCENE-5803: Add a Solr test that we reuse analysis components across fields for the same field type
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/9f7f76f2
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/9f7f76f2
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/9f7f76f2
Branch: refs/heads/jira/solr-11702
Commit: 9f7f76f267bd46b0069731ba1ae4990d31c33df8
Parents: 79073fa
Author: David Smiley <ds...@apache.org>
Authored: Tue Dec 19 10:28:22 2017 -0500
Committer: David Smiley <ds...@apache.org>
Committed: Tue Dec 19 10:28:22 2017 -0500
----------------------------------------------------------------------
.../miscellaneous/TestPerFieldAnalyzerWrapper.java | 2 ++
.../test/org/apache/solr/schema/IndexSchemaTest.java | 14 ++++++++++++++
2 files changed, 16 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9f7f76f2/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestPerFieldAnalyzerWrapper.java
----------------------------------------------------------------------
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestPerFieldAnalyzerWrapper.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestPerFieldAnalyzerWrapper.java
index 903076d..54a64ce 100644
--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestPerFieldAnalyzerWrapper.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestPerFieldAnalyzerWrapper.java
@@ -88,7 +88,9 @@ public class TestPerFieldAnalyzerWrapper extends BaseTokenStreamTestCase {
// test that the PerFieldWrapper returns the same instance as original Analyzer:
ts1 = defaultAnalyzer.tokenStream("something", text);
ts2 = wrapper1.tokenStream("something", text);
+ ts3 = wrapper1.tokenStream("somethingElse", text);
assertSame(ts1, ts2);
+ assertSame(ts2, ts3);
ts1 = specialAnalyzer.tokenStream("special", text);
ts2 = wrapper1.tokenStream("special", text);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9f7f76f2/solr/core/src/test/org/apache/solr/schema/IndexSchemaTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/schema/IndexSchemaTest.java b/solr/core/src/test/org/apache/solr/schema/IndexSchemaTest.java
index 4719f04..6bfa14f 100644
--- a/solr/core/src/test/org/apache/solr/schema/IndexSchemaTest.java
+++ b/solr/core/src/test/org/apache/solr/schema/IndexSchemaTest.java
@@ -17,6 +17,8 @@
package org.apache.solr.schema;
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.TokenStream;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.MapSolrParams;
@@ -115,4 +117,16 @@ public class IndexSchemaTest extends SolrTestCaseJ4 {
6, ((TrieDateField)tdatedv).getPrecisionStep());
}
}
+
+ @Test // LUCENE-5803
+ public void testReuseAnalysisComponents() throws Exception {
+ IndexSchema schema = h.getCore().getLatestSchema();
+ Analyzer solrAnalyzer = schema.getIndexAnalyzer();
+ // Get the tokenStream for two fields that both have the same field type (name "text")
+ TokenStream ts1 = solrAnalyzer.tokenStream("text", "foo bar"); // a non-dynamic field
+ TokenStream ts2 = solrAnalyzer.tokenStream("t_text", "whatever"); // a dynamic field
+ assertSame(ts1, ts2);
+ ts1.close();
+ ts2.close();
+ }
}