[英]Hibernate search on multi fields
我想對實體進行全文搜索。
當我使用單個關鍵字但沒有更多關鍵字時,它可以工作。
Query luceneQuery = qb
.keyword()
.wildcard()
.onFields("description", "brand" )
.matching("*" + searchTerm + "*").createQuery();
在一種情況下,我有一個描述等於“汽車”且品牌等於“福特”的實體
如果查詢是“ car”或“ ford”而不是“ car ford”,則搜索將返回預期結果
有任何想法嗎 ?
謝謝
Query query = qb.bool()
.should( qb.keyword().fuzzy().onField("description").ignoreFieldBridge().matching(searchTerm).createQuery() )
.should( qb.keyword().fuzzy().onField("color").ignoreFieldBridge().matching(searchTerm).createQuery() )
.should(qb.keyword().fuzzy().onField("brand").matching(searchTerm).createQuery() )
.createQuery();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.