From 047766737615153d3abea35a53830def10d90a43 Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Mon, 12 Jan 2015 16:07:45 +0000 Subject: [PATCH] LUCENE-5900: Fix remaining issues with default matchVersion git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1651127 13f79535-47bb-0310-9956-ffa450edef68 --- .../DictionaryCompoundWordTokenFilterFactory.java | 1 - .../HyphenationCompoundWordTokenFilterFactory.java | 1 - .../miscellaneous/CapitalizationFilterFactory.java | 1 - .../StemmerOverrideFilterFactory.java | 1 - .../miscellaneous/WordDelimiterFilterFactory.java | 1 - .../analysis/synonym/SynonymFilterFactory.java | 1 - .../analysis/util/AbstractAnalysisFactory.java | 14 +------------- 7 files changed, 1 insertion(+), 19 deletions(-) diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/DictionaryCompoundWordTokenFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/DictionaryCompoundWordTokenFilterFactory.java index cc461f4cfcb..25d4a745339 100644 --- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/DictionaryCompoundWordTokenFilterFactory.java +++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/DictionaryCompoundWordTokenFilterFactory.java @@ -48,7 +48,6 @@ public class DictionaryCompoundWordTokenFilterFactory extends TokenFilterFactory /** Creates a new DictionaryCompoundWordTokenFilterFactory */ public DictionaryCompoundWordTokenFilterFactory(Map args) { super(args); - assureMatchVersion(); dictFile = require(args, "dictionary"); minWordSize = getInt(args, "minWordSize", CompoundWordTokenFilterBase.DEFAULT_MIN_WORD_SIZE); minSubwordSize = getInt(args, "minSubwordSize", CompoundWordTokenFilterBase.DEFAULT_MIN_SUBWORD_SIZE); diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/HyphenationCompoundWordTokenFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/HyphenationCompoundWordTokenFilterFactory.java index d4b04f4b2ed..84791827851 100644 --- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/HyphenationCompoundWordTokenFilterFactory.java +++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/HyphenationCompoundWordTokenFilterFactory.java @@ -74,7 +74,6 @@ public class HyphenationCompoundWordTokenFilterFactory extends TokenFilterFactor /** Creates a new HyphenationCompoundWordTokenFilterFactory */ public HyphenationCompoundWordTokenFilterFactory(Map args) { super(args); - assureMatchVersion(); dictFile = get(args, "dictionary"); encoding = get(args, "encoding"); hypFile = require(args, "hyphenator"); diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/CapitalizationFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/CapitalizationFilterFactory.java index 8159d8affd1..cc343914946 100644 --- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/CapitalizationFilterFactory.java +++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/CapitalizationFilterFactory.java @@ -78,7 +78,6 @@ public class CapitalizationFilterFactory extends TokenFilterFactory { /** Creates a new CapitalizationFilterFactory */ public CapitalizationFilterFactory(Map args) { super(args); - assureMatchVersion(); boolean ignoreCase = getBoolean(args, KEEP_IGNORE_CASE, false); Set k = getSet(args, KEEP); if (k != null) { diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/StemmerOverrideFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/StemmerOverrideFilterFactory.java index b56fe763cb8..450af5c56e5 100644 --- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/StemmerOverrideFilterFactory.java +++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/StemmerOverrideFilterFactory.java @@ -55,7 +55,6 @@ public class StemmerOverrideFilterFactory extends TokenFilterFactory implements @Override public void inform(ResourceLoader loader) throws IOException { if (dictionaryFiles != null) { - assureMatchVersion(); List files = splitFileNames(dictionaryFiles); if (files.size() > 0) { StemmerOverrideFilter.Builder builder = new StemmerOverrideFilter.Builder(ignoreCase); diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterFilterFactory.java index 9ab83c8ff66..a7bd468672f 100644 --- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterFilterFactory.java +++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterFilterFactory.java @@ -63,7 +63,6 @@ public class WordDelimiterFilterFactory extends TokenFilterFactory implements Re /** Creates a new WordDelimiterFilterFactory */ public WordDelimiterFilterFactory(Map args) { super(args); - assureMatchVersion(); int flags = 0; if (getInt(args, "generateWordParts", 1) != 0) { flags |= GENERATE_WORD_PARTS; diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymFilterFactory.java index c5afd87bf45..c8b01c59e04 100644 --- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymFilterFactory.java +++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymFilterFactory.java @@ -102,7 +102,6 @@ public class SynonymFilterFactory extends TokenFilterFactory implements Resource } if (tokenizerFactory != null) { - assureMatchVersion(); tokArgs.put("luceneMatchVersion", getLuceneMatchVersion().toString()); for (Iterator itr = args.keySet().iterator(); itr.hasNext();) { String key = itr.next(); diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/AbstractAnalysisFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/AbstractAnalysisFactory.java index 9c756510754..bc48531ae5a 100644 --- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/AbstractAnalysisFactory.java +++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/AbstractAnalysisFactory.java @@ -70,7 +70,7 @@ public abstract class AbstractAnalysisFactory { originalArgs = Collections.unmodifiableMap(new HashMap<>(args)); String version = get(args, LUCENE_MATCH_VERSION_PARAM); if (version == null) { - luceneMatchVersion = null; + luceneMatchVersion = Version.LATEST; } else { try { luceneMatchVersion = Version.parseLeniently(version); @@ -85,16 +85,6 @@ public abstract class AbstractAnalysisFactory { return originalArgs; } - /** this method can be called in the {@link org.apache.lucene.analysis.util.TokenizerFactory#create()} - * or {@link org.apache.lucene.analysis.util.TokenFilterFactory#create(org.apache.lucene.analysis.TokenStream)} methods, - * to inform user, that for this factory a {@link #luceneMatchVersion} is required */ - protected final void assureMatchVersion() { - if (luceneMatchVersion == null) { - throw new IllegalArgumentException("Configuration Error: Factory '" + this.getClass().getName() + - "' needs a 'luceneMatchVersion' parameter"); - } - } - public final Version getLuceneMatchVersion() { return this.luceneMatchVersion; } @@ -241,7 +231,6 @@ public abstract class AbstractAnalysisFactory { */ protected final CharArraySet getWordSet(ResourceLoader loader, String wordFiles, boolean ignoreCase) throws IOException { - assureMatchVersion(); List files = splitFileNames(wordFiles); CharArraySet words = null; if (files.size() > 0) { @@ -267,7 +256,6 @@ public abstract class AbstractAnalysisFactory { * except the input is in snowball format. */ protected final CharArraySet getSnowballWordSet(ResourceLoader loader, String wordFiles, boolean ignoreCase) throws IOException { - assureMatchVersion(); List files = splitFileNames(wordFiles); CharArraySet words = null; if (files.size() > 0) {