休眠搜索,现有数据不可搜索
hibernate search, existing data not searchable
我似乎在休眠搜索的初始化过程中遗漏了一些东西。
我的 mysql 数据库 table 包含一些现有的行,这些行似乎 return 编辑为结果的一部分
我在启动后通过应用程序添加的任何新行似乎在休眠搜索中 returned
我需要 return 所有行,包括 table 中已经存在的行,我需要添加什么才能得到它?
这是我用来查询的代码段
// 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();
您需要 运行 mass indexer 将所有那些 added/updated 尚未启用 Hibernate Search 的实体添加到索引中。
这将从数据库中获取所有实体并更新相应的索引。最简单的形式是这样完成的:
fullTextEntityManager
.createIndexer( Entity.class )
.startAndWait();
参考指南详细描述了微调的所有选项。
我似乎在休眠搜索的初始化过程中遗漏了一些东西。
我的 mysql 数据库 table 包含一些现有的行,这些行似乎 return 编辑为结果的一部分
我在启动后通过应用程序添加的任何新行似乎在休眠搜索中 returned
我需要 return 所有行,包括 table 中已经存在的行,我需要添加什么才能得到它?
这是我用来查询的代码段
// 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();
您需要 运行 mass indexer 将所有那些 added/updated 尚未启用 Hibernate Search 的实体添加到索引中。
这将从数据库中获取所有实体并更新相应的索引。最简单的形式是这样完成的:
fullTextEntityManager
.createIndexer( Entity.class )
.startAndWait();
参考指南详细描述了微调的所有选项。