[英]hibernate search, existing data not searchable
我似乎在休眠搜索初始化期間丟失了一些內容。
我的mysql數據庫表包含一些現有行,這些行似乎未作為結果的一部分返回
在啟動之后,我通過應用程序添加的任何新行似乎都在休眠搜索中返回
我需要返回所有行,包括表中已經存在的行,我需要添加什么才能獲得它?
這是我用來查詢的代碼部分
// get the full text entity manager
FullTextEntityManager fullTextEntityManager=Search.getFullTextEntityManager(entityManager);
//create query using hibernate query DSL
QueryBuilder queryBuilder=fullTextEntityManager.getSearchFactory().buildQueryBuilder().forEntity(Entity.class).get();
// actual query
Query query=queryBuilder.keyword()
.onFields("col1","col2","col3")
.matching(searchKeyword)
.createQuery();
//wrap Lucene query in hibernate query object
FullTextQuery jpaQuery=fullTextEntityManager.createFullTextQuery(query, Entity.class);
return jpaQuery.getResultList();
您需要運行質量索引器,以將尚未(尚未)啟用Hibernate Search時已添加/更新的所有那些實體添加到索引中。
這將從數據庫中獲取所有實體,並更新相應的索引。 最簡單的形式是這樣的:
fullTextEntityManager
.createIndexer( Entity.class )
.startAndWait();
參考指南詳細介紹了所有用於微調的選項。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.