i seem to be missing something during initialisation of hibernate search.
my mysql database table contains a few existing rows which dont seem to be returned as part of the results
any new rows that i add through the application after starting it seem to be returned in the hibernate search
i need to return all rows including the ones already existing in the table, what do i need to add to get it?
this is the code section i use to query
// 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();
You need to run the mass indexer to add all those entities to the index which have been added/updated while Hibernate Search was not (yet) enabled.
This will fetch all the entities from the database und update the corresponding index(es). In its simplest form it's done like so:
fullTextEntityManager
.createIndexer( Entity.class )
.startAndWait();
The reference guide describes all the options for fine-tuning in detail.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.