fix new analysis components test, and make pattern require parameters
This commit is contained in:
parent
7e20a9f80a
commit
66d5eb94fb
|
@ -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'");
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue