0
搜索的人的姓名是「Suleman Kumar With」,並且是姓氏。 它工作正常的所有其他名稱,但不是這個英文關鍵字如何使用Lucene/Hibernate搜索具有關鍵字「With」的名稱?
以下是辦法,我創造的Lucene索引:
@Fields({ @Field(index = Index.YES, store = Store.NO),
@Field(name = "LastName_Sort", index = Index.YES, analyzer = @Analyzer(definition = "sortAnalyzer")) })
@Column(name = "LASTNAME", length = 50)
public String getLastName() {
return lastName;
}
sortAnalyzer有以下配置:
@AnalyzerDef(name = "sortAnalyzer",
tokenizer = @TokenizerDef(factory = KeywordTokenizerFactory.class),
filters = {
@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")
})
}
)
有搜索上姓氏以及主鍵:ID,我在那裏得到令牌不匹配錯誤。