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:
parent
08e35e4dbe
commit
eb75a815db
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue