在hibernate搜索的初始化过程中,我似乎遗漏了一些东西。
我的mysql数据库表包含一些现有行,这些行似乎不作为结果的一部分返回。
启动应用程序后通过应用程序添加的任何新行似乎都会在hibernate搜索中返回。
我需要返回所有行,包括表中已经存在的行,需要添加什么才能得到它?
这是我用来查询的代码部分。
// 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();
发布于 2015-12-08 02:32:38
您需要运行质量索引器来将所有这些实体添加到索引中,这些实体已经被添加/更新,而Hibernate搜索(尚未启用)。
这将从数据库中获取所有实体,并更新相应的索引(Es)。最简单的方式是这样做的:
fullTextEntityManager
.createIndexer( Entity.class )
.startAndWait();
参考指南详细描述了微调的所有选项。
https://stackoverflow.com/questions/34147336
复制