0
我有UUID通過使用PatternTokenizerFactory
正確索引爲一個完整的單詞,例如024bb09c-86b4-4d73-8483-bf7839e407d8
。休眠搜索如何正確搜索UUID
但搜索時,這種滿弦的查詢將返回一個錯誤,
The query string '024bb09c-86b4-4d73-8483-bf7839e407d8' applied on field 'id' has no meaningfull tokens to be matched. Validate the query input against the Analyzer applied on this field.
這是否意味着我需要設置具體分析,在準備好查詢?
,報告這個錯誤的代碼如下,
lucene = builder.keyword()
.onFields("id", "status", "submitter")
.matching(keyword)
.createQuery();
編輯:
下面是用於索引的分析,我們的原料id爲group/UUID
形式,所以我用一個PatternTokenizer要刪除前綴,
@AnalyzerDef(
name = "idanalyzer",
tokenizer = @TokenizerDef(
factory = PatternTokenizerFactory.class,
params = {
@Parameter(name = "pattern", value = ".*/(.*)"),
@Parameter(name = "group", value = "1")
}
),
filters = {
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
}
)
這裏是在實體代碼,
@Id
@DocumentId
@Analyzer(definition = "idanalyzer")
private String id;
你看過這篇文章http://stackoverflow.com/questions/12753642/searching-for-uuid-in-lucene-not-working? – Filip
請分享實體映射,至少如何將id編入索引。 – Sanne
聽起來像這樣的問題可能是,一旦分析器完成它,查詢就沒有了。你的分析儀是什麼樣的? – femtoRgon