From 66d5eb94fbe6a8b39ebe64f18c606bc64f58492e Mon Sep 17 00:00:00 2001 From: kimchy Date: Fri, 8 Jul 2011 22:28:26 +0300 Subject: [PATCH] fix new analysis components test, and make pattern require parameters --- .../index/analysis/PatternReplaceTokenFilterFactory.java | 7 +++---- .../elasticsearch/index/analysis/AnalysisModuleTests.java | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/analysis/PatternReplaceTokenFilterFactory.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/analysis/PatternReplaceTokenFilterFactory.java index 3da149ee8e7..2893025c5f9 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/analysis/PatternReplaceTokenFilterFactory.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/analysis/PatternReplaceTokenFilterFactory.java @@ -29,10 +29,9 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; -import java.io.IOException; -import java.io.Reader; import java.util.regex.Pattern; +@AnalysisSettingsRequired public class PatternReplaceTokenFilterFactory extends AbstractTokenFilterFactory { private final Pattern pattern; @@ -42,14 +41,14 @@ public class PatternReplaceTokenFilterFactory extends AbstractTokenFilterFactory @Inject public PatternReplaceTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); - String sPattern = settings.get("pattern", ""); + String sPattern = settings.get("pattern", null); if (sPattern == null) { throw new ElasticSearchIllegalArgumentException("pattern is missing for [" + name + "] token filter of type 'pattern_replace'"); } this.pattern = Regex.compile(sPattern, settings.get("flags")); - String sReplacement = settings.get("replacement", ""); + String sReplacement = settings.get("replacement", null); if (sReplacement == null) { throw new ElasticSearchIllegalArgumentException("replacement is missing for [" + name + "] token filter of type 'pattern_replace'"); } diff --git a/modules/elasticsearch/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java b/modules/elasticsearch/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java index 3f25630796c..a2cb36fe2a8 100644 --- a/modules/elasticsearch/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java +++ b/modules/elasticsearch/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java @@ -98,7 +98,7 @@ public class AnalysisModuleTests { analyzer = analysisService.analyzer("custom5").analyzer(); assertThat(analyzer, instanceOf(CustomAnalyzer.class)); CustomAnalyzer custom5 = (CustomAnalyzer) analyzer; - assertThat(custom5.tokenFilters()[0], instanceOf(MappingCharFilterFactory.class)); + assertThat(custom5.charFilters()[0], instanceOf(MappingCharFilterFactory.class)); // verify aliases analyzer = analysisService.analyzer("alias1").analyzer();