diff --git a/src/main/java/com/yelp/nrtsearch/server/luceneserver/analysis/MappingV2CharFilterFactory.java b/src/main/java/com/yelp/nrtsearch/server/luceneserver/analysis/MappingV2CharFilterFactory.java index 210f9c735..bd4c1d4bf 100644 --- a/src/main/java/com/yelp/nrtsearch/server/luceneserver/analysis/MappingV2CharFilterFactory.java +++ b/src/main/java/com/yelp/nrtsearch/server/luceneserver/analysis/MappingV2CharFilterFactory.java @@ -91,7 +91,7 @@ private List extractRules(String mappings, String separator) { return Arrays.asList(mappings.split(separator)); } - static Pattern p = Pattern.compile("(.*)\\s*=>\\s*(.*)\\s*$"); + static Pattern p = Pattern.compile("(.*)=>(.*)$"); protected void parseRules(List rules, NormalizeCharMap.Builder builder) { for (String rule : rules) { diff --git a/src/test/java/com/yelp/nrtsearch/server/luceneserver/analysis/MappingV2CharFilterFactoryTest.java b/src/test/java/com/yelp/nrtsearch/server/luceneserver/analysis/MappingV2CharFilterFactoryTest.java index 70786aa15..e10b74df9 100644 --- a/src/test/java/com/yelp/nrtsearch/server/luceneserver/analysis/MappingV2CharFilterFactoryTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/luceneserver/analysis/MappingV2CharFilterFactoryTest.java @@ -54,6 +54,13 @@ public void testDifferentSeparator() throws IOException { assertEquals("abc and d n e'n'f g hi", output); } + @Test + public void testWhitespaceInRule() throws IOException { + MappingV2CharFilterFactory factory = getFactory(". =>|,=> "); + String output = getFiltered(factory, "this. is, a test, string"); + assertEquals("thisis a test string", output); + } + @Test public void testNoMappings() { try {