您可以
org.apache.lucene.collation.CollationKeyFilter在Hibernate
Search版本4.3.0.Final中使用类。创建自己的归类过滤器工厂:
import org.apache.lucene.analysis.TokenStream;import org.apache.lucene.collation.CollationKeyFilter;import org.apache.solr.analysis.baseTokenFilterFactory;import java.text.Collator;import java.util.Locale;public final class NorwegianCollationFactory extends baseTokenFilterFactory { @Override public TokenStream create(TokenStream input) { Collator norwegianCollator = Collator.getInstance(new Locale("no", "NO")); return new CollationKeyFilter(input, norwegianCollator); }}
并在AnalyzerDef中使用以下整理工厂:
@AnalyzerDef(name = "myOwnAnalyzer",tokenizer = @TokenizerDef(factory = KeywordTokenizerFactory.class),filters = { @TokenFilterDef(factory = ASCIIFoldingFilterFactory.class), @TokenFilterDef(factory = LowerCaseFilterFactory.class), @TokenFilterDef(factory = PatternReplaceFilterFactory.class, params = { @Parameter(name = "pattern", value = "('-&\.,\(\))"), @Parameter(name = "replacement", value = " "), @Parameter(name = "replace", value = "all") }), @TokenFilterDef(factory = PatternReplaceFilterFactory.class, params = { @Parameter(name = "pattern", value = "([^0-9\p{L} ])"), @Parameter(name = "replacement", value = ""), @Parameter(name = "replace", value = "all") }), @TokenFilterDef(factory = TrimFilterFactory.class), @TokenFilterDef(factory = NorwegianCollationFactory .class)})public class KikaPaya implements Serializable {
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)