pattern replace with empty "" setting fails

we should default the replacement to "", since in the settings, if its set to "", we remove the setting
This commit is contained in:
Shay Banon 2013-07-19 17:12:27 +02:00
parent 08e35e4dbe
commit eb75a815db
2 changed files with 2 additions and 14 deletions

View File

@ -44,11 +44,7 @@ public class PatternReplaceCharFilterFactory extends AbstractCharFilterFactory {
throw new ElasticSearchIllegalArgumentException("pattern is missing for [" + name + "] char filter of type 'pattern_replace'");
}
pattern = Pattern.compile(settings.get("pattern"));
replacement = settings.get("replacement");
if (!Strings.hasLength(replacement)) {
throw new ElasticSearchIllegalArgumentException("replacement is missing for [" + name + "] char filter of type 'pattern_replace'");
}
replacement = settings.get("replacement", ""); // when not set or set to "", use "".
}
public Pattern getPattern() {

View File

@ -46,16 +46,8 @@ public class PatternReplaceTokenFilterFactory extends AbstractTokenFilterFactory
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", null);
if (sReplacement == null) {
throw new ElasticSearchIllegalArgumentException("replacement is missing for [" + name + "] token filter of type 'pattern_replace'");
}
this.replacement = sReplacement;
this.replacement = settings.get("replacement", "");
this.all = settings.getAsBoolean("all", true);
}