You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by th...@apache.org on 2015/01/14 19:53:32 UTC
svn commit: r1651772 - in /lucene/dev/branches/branch_5x: ./ solr/
solr/CHANGES.txt solr/core/
solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java
Author: thelabdude
Date: Wed Jan 14 18:53:32 2015
New Revision: 1651772
URL: http://svn.apache.org/r1651772
Log:
SOLR-6764: Field types need to be re-informed after reloading a managed schema from ZK
Modified:
lucene/dev/branches/branch_5x/ (props changed)
lucene/dev/branches/branch_5x/solr/ (props changed)
lucene/dev/branches/branch_5x/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_5x/solr/core/ (props changed)
lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java
Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1651772&r1=1651771&r2=1651772&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Wed Jan 14 18:53:32 2015
@@ -403,6 +403,9 @@ Bug Fixes
* SOLR-6941: DistributedQueue#containsTaskWithRequestId can fail with NPE. (Mark Miller)
+* SOLR-6764: Field types need to be re-informed after reloading a managed schema from ZK
+ (Timothy Potter)
+
* SOLR-6931: We should do a limited retry when using HttpClient.
(Mark Miller, Hrishikesh Gadre, Gregory Chanan)
Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java?rev=1651772&r1=1651771&r2=1651772&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java Wed Jan 14 18:53:32 2015
@@ -560,34 +560,8 @@ public final class ManagedIndexSchema ex
aware.inform(newSchema);
// looks good for the add, notify ResoureLoaderAware objects
- for (FieldType fieldType : fieldTypeList) {
-
- // must inform any sub-components used in the
- // tokenizer chain if they are ResourceLoaderAware
- if (fieldType.supportsAnalyzers()) {
- Analyzer indexAnalyzer = fieldType.getIndexAnalyzer();
- if (indexAnalyzer != null && indexAnalyzer instanceof TokenizerChain)
- informResourceLoaderAwareObjectsInChain((TokenizerChain)indexAnalyzer);
-
- Analyzer queryAnalyzer = fieldType.getQueryAnalyzer();
- // ref comparison is correct here (vs. equals) as they may be the same
- // object in which case, we don't need to inform twice ... however, it's
- // actually safe to call inform multiple times on an object anyway
- if (queryAnalyzer != null &&
- queryAnalyzer != indexAnalyzer &&
- queryAnalyzer instanceof TokenizerChain)
- informResourceLoaderAwareObjectsInChain((TokenizerChain)queryAnalyzer);
-
- // if fieldType is a TextField, it might have a multi-term analyzer
- if (fieldType instanceof TextField) {
- TextField textFieldType = (TextField)fieldType;
- Analyzer multiTermAnalyzer = textFieldType.getMultiTermAnalyzer();
- if (multiTermAnalyzer != null && multiTermAnalyzer != indexAnalyzer &&
- multiTermAnalyzer != queryAnalyzer && multiTermAnalyzer instanceof TokenizerChain)
- informResourceLoaderAwareObjectsInChain((TokenizerChain)multiTermAnalyzer);
- }
- }
- }
+ for (FieldType fieldType : fieldTypeList)
+ informResourceLoaderAwareObjectsForFieldType(fieldType);
newSchema.refreshAnalyzers();
@@ -611,7 +585,39 @@ public final class ManagedIndexSchema ex
}
return newSchema;
- }
+ }
+
+ /**
+ * Informs analyzers used by a fieldType.
+ */
+ protected void informResourceLoaderAwareObjectsForFieldType(FieldType fieldType) {
+ // must inform any sub-components used in the
+ // tokenizer chain if they are ResourceLoaderAware
+ if (!fieldType.supportsAnalyzers())
+ return;
+
+ Analyzer indexAnalyzer = fieldType.getIndexAnalyzer();
+ if (indexAnalyzer != null && indexAnalyzer instanceof TokenizerChain)
+ informResourceLoaderAwareObjectsInChain((TokenizerChain)indexAnalyzer);
+
+ Analyzer queryAnalyzer = fieldType.getQueryAnalyzer();
+ // ref comparison is correct here (vs. equals) as they may be the same
+ // object in which case, we don't need to inform twice ... however, it's
+ // actually safe to call inform multiple times on an object anyway
+ if (queryAnalyzer != null &&
+ queryAnalyzer != indexAnalyzer &&
+ queryAnalyzer instanceof TokenizerChain)
+ informResourceLoaderAwareObjectsInChain((TokenizerChain)queryAnalyzer);
+
+ // if fieldType is a TextField, it might have a multi-term analyzer
+ if (fieldType instanceof TextField) {
+ TextField textFieldType = (TextField)fieldType;
+ Analyzer multiTermAnalyzer = textFieldType.getMultiTermAnalyzer();
+ if (multiTermAnalyzer != null && multiTermAnalyzer != indexAnalyzer &&
+ multiTermAnalyzer != queryAnalyzer && multiTermAnalyzer instanceof TokenizerChain)
+ informResourceLoaderAwareObjectsInChain((TokenizerChain)multiTermAnalyzer);
+ }
+ }
@Override
public SchemaField newField(String fieldName, String fieldType, Map<String,?> options) {
@@ -786,6 +792,11 @@ public final class ManagedIndexSchema ex
for (SchemaAware aware : newSchema.schemaAware) {
aware.inform(newSchema);
}
+
+ // notify analyzers and other objects for our fieldTypes
+ for (FieldType fieldType : newSchema.fieldTypes.values())
+ informResourceLoaderAwareObjectsForFieldType(fieldType);
+
newSchema.refreshAnalyzers();
newSchema.schemaZkVersion = schemaZkVersion;
} catch (SolrException e) {