From 18078af958cac25fc84341ce4ecc6e73b8d126d0 Mon Sep 17 00:00:00 2001 From: Erik Hatcher Date: Fri, 31 Jul 2009 12:54:02 +0000 Subject: [PATCH] SOLR-1317: Fix CapitalizationFilterFactory to work when keep parameter is not specified git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@799593 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 3 +++ .../apache/solr/analysis/CapitalizationFilterFactory.java | 2 +- .../org/apache/solr/analysis/TestCapitalizationFilter.java | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index c4247c0ade1..c8eff2ed87c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -449,6 +449,9 @@ Bug Fixes SolrQueryParser considers special. (hossman) +54. SOLR-1317: Fix CapitalizationFilterFactory to work when keep parameter is not specified. + (ehatcher) + Other Changes ---------------------- 1. Upgraded to Lucene 2.4.0 (yonik) diff --git a/src/java/org/apache/solr/analysis/CapitalizationFilterFactory.java b/src/java/org/apache/solr/analysis/CapitalizationFilterFactory.java index db6377f923c..96dcf46df71 100644 --- a/src/java/org/apache/solr/analysis/CapitalizationFilterFactory.java +++ b/src/java/org/apache/solr/analysis/CapitalizationFilterFactory.java @@ -141,7 +141,7 @@ public class CapitalizationFilterFactory extends BaseTokenFilterFactory { return; } - if (keep.contains(buffer, offset, length)) { + if (keep != null && keep.contains(buffer, offset, length)) { if (wordCount == 0 && forceFirstLetter) { buffer[offset] = Character.toUpperCase(buffer[offset]); } diff --git a/src/test/org/apache/solr/analysis/TestCapitalizationFilter.java b/src/test/org/apache/solr/analysis/TestCapitalizationFilter.java index 7e13787a5f0..a2798a7332d 100644 --- a/src/test/org/apache/solr/analysis/TestCapitalizationFilter.java +++ b/src/test/org/apache/solr/analysis/TestCapitalizationFilter.java @@ -17,6 +17,8 @@ package org.apache.solr.analysis; +import junit.framework.TestCase; + import java.util.HashMap; import java.util.Map; @@ -115,5 +117,10 @@ public class TestCapitalizationFilter extends BaseTokenTestCase { termBuffer = "kiTTEN".toCharArray(); factory.processWord(termBuffer, 0, termBuffer.length, 0 ); assertEquals( "kiTTEN", new String(termBuffer, 0, termBuffer.length)); + + factory.keep = null; + termBuffer = "kiTTEN".toCharArray(); + factory.processWord(termBuffer, 0, termBuffer.length, 0 ); + assertEquals( "Kitten", new String(termBuffer, 0, termBuffer.length)); } }