![](/img/trans.png)
[英]Hibernate-search: Base class fields are not registered in elastic-search by registering the fields programmatically in hibernate-search
[英]Is there a way in hibernate-search to facet by fields where the search term was found?
考慮以下索引實體:
@Entity
@Indexed
public class Document {
...
@Field
private String title;
@Field
private String text;
}
有沒有一種方法可以向用戶顯示一個包含兩個選項的title
和text
,以及帶有分別在title
和text
找到搜索詞的文檔數量的構面? 用戶應該能夠選擇這些選項以僅按感興趣的字段進行搜索。
例如,有三個文檔:
{ "title" : "One", "text" : "One" }
{ "title" : "One and Two", "text" : "Two" }
{ "title" : "Three", "text" : "Three and Two" }
搜索查詢為“一個”:那么構面為:
{ "title" : 2, "text" : 1 }
Hibernate Search中沒有此類內置功能,但您可以自己完成。 而不是運行單個查詢,而是運行三個:
然后從第一個查詢收集結果,從第二個查詢收集“ title”方面,從第三個查詢收集“ text”方面。
有關Hibernate搜索中的方面的更多信息: https : //docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#query-faceting
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.