@Entity @Indexed @AnalyzerDefs({ @AnalyzerDef(name = "en", tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class), filters = { @TokenFilterDef(factory = LowerCaseFilterFactory.class), @TokenFilterDef(factory = EnglishPorterFilterFactory.class ) }), @AnalyzerDef(name = "de", tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class), filters = { @TokenFilterDef(factory = LowerCaseFilterFactory.class), @TokenFilterDef(factory = GermanStemFilterFactory.class) }) }) public class BlogEntry { @Id @GeneratedValue @DocumentId private Integer id; @Field @AnalyzerDiscriminator(impl = LanguageDiscriminator.class) private String language; @Field private String text; private Set<BlogEntry> references; // standard getter/setter // ... } public class LanguageDiscriminator implements Discriminator { public String getAnalyzerDefinitionName(Object value, Object entity, String field) { if ( value == null || !( entity instanceof Article ) ) { return null; } return (String) value; } }
从参考文档, 我怎样可以使用现有的分析一样org.apache.lucene.analysis.cjk.CJKAnalyzer,沿en和de我所动态定义的呢?我只能在此处返回分析器的名称,返回时我CJKAnalyzer未定义分析器。
org.apache.lucene.analysis.cjk.CJKAnalyzer
en
de
CJKAnalyzer
如何将现有分析仪添加到分析仪定义中?
这是一个很好的问题,我很惊讶以前没有人问过这个问题。
答案是不可能的。
我已经在项目中打开了功能请求,以对此进行改进: