【发布时间】:2017-11-04 23:23:51
【问题描述】:
我需要自定义停用词列表以按 Document 标题搜索。
我有以下映射:
@Entity
@Indexed
@AnalyzerDef(
name = "documentAnalyzer",
tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
filters = {
@TokenFilterDef(factory = ASCIIFoldingFilterFactory.class),
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
@TokenFilterDef(
factory = StopFilterFactory.class,
params = {
@Parameter(name = "words", value = "stoplist.properties"),
@Parameter(name = "ignoreCase", value = "true")
}
)
}
)
public class Document {
...
@Field(analyzer = @Analyzer(definition = "documentAnalyzer"))
private String title;
...
}
stoplist.properties 文件位于resources 目录中,并且包含不同于StandardAnalyzer 默认值的停用词。
但如果我使用默认启用但在我的stoplist.properties 文件中不存在的停用词,则搜索不会返回任何结果,例如will这个词。
当前配置有什么问题? 如何让休眠搜索使用自定义停用词列表?
我使用的是 hibernate-search-orm 5.6.1 版本。
在集成测试中通过即时创建的索引验证结果:
@Before
public void setUpLuceneIndex() throws InterruptedException {
FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
fullTextEntityManager.createIndexer().startAndWait();
}
【问题讨论】:
标签: java hibernate lucene hibernate-search