diff --git a/src/main/java/com/yelp/nrtsearch/server/analysis/MappingV2CharFilterFactory.java b/src/main/java/com/yelp/nrtsearch/server/analysis/MappingV2CharFilterFactory.java index 83f5f7c4a..f436d4f91 100644 --- a/src/main/java/com/yelp/nrtsearch/server/analysis/MappingV2CharFilterFactory.java +++ b/src/main/java/com/yelp/nrtsearch/server/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/analysis/MappingV2CharFilterFactoryTest.java b/src/test/java/com/yelp/nrtsearch/server/analysis/MappingV2CharFilterFactoryTest.java index 147c1613c..2da762d9f 100644 --- a/src/test/java/com/yelp/nrtsearch/server/analysis/MappingV2CharFilterFactoryTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/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 {