Apache Solr open-source search software
configurable language for SnowballPorterFilterFactory: SOLR-27
Yonik Seeley8e9950debb1a
diff --git a/CHANGES.txt b/CHANGES.txtindex eb76c64e698..fd95d30614e 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -27,6 +27,8 @@ New Featuresthe same position. (SOLR-11 / yonik, hossman)15. Added highlighting to SolrPluginUtils and implemented in StandardRequestHandlerand DisMaxRequestHandler (SOLR-24 / Mike Klaas via hossman,yonik)+16. SnowballPorterFilterFactory language is configurable via the "language"+ attribute, with the default being "English". (Bertrand Delacretaz via yonik, SOLR-27)Changes in runtime behavior1. classes reorganized into different packages, package names changed to Apachediff --git a/src/java/org/apache/solr/analysis/SnowballPorterFilterFactory.java b/src/java/org/apache/solr/analysis/SnowballPorterFilterFactory.javaindex c5ab0d5c32e..ba63e4febc3 100644--- a/src/java/org/apache/solr/analysis/SnowballPorterFilterFactory.java+++ b/src/java/org/apache/solr/analysis/SnowballPorterFilterFactory.java@@ -13,22 +13,36 @@* See the License for the specific language governing permissions and* limitations under the License.*/-package org.apache.solr.analysis;+import java.util.Map;+import org.apache.lucene.analysis.TokenStream;import org.apache.lucene.analysis.snowball.SnowballFilter;+import org.apache.solr.core.SolrCore;/**+ * Factory for SnowballFilters, with configurable language+ *+ * Browsing the code, SnowballFilter uses reflection to adapt to Lucene... don't+ * use this if you are concerned about speed. Use EnglishPorterFilterFactory.+ ** @author yonik* @version $Id$*/+public class SnowballPorterFilterFactory extends BaseTokenFilterFactory {+ private String language = "English";++ public void init(Map<String, String> args) {+ super.init(args);+ final String cfgLanguage = args.get("language");+ if(cfgLanguage!=null) language = cfgLanguage;+ SolrCore.log.fine("SnowballPorterFilterFactory: language=" + language);+ }+public TokenStream create(TokenStream input) {- // Browsing the code, SnowballFilter uses reflection to adapt to Lucene...- // don't use this if you are concerned about speed. Use EnglishPorterFilterFactory.-- // TODO: make language configurable- return new SnowballFilter(input,"English");+ return new SnowballFilter(input,language);}}+