Hibernate Search: why .getResultsize is greater than .list().size()? -
the similar question asked not solved. here code
fulltextsession fulltextsession = search.getfulltextsession(currentsession()); querybuilder qb = fulltextsession.getsearchfactory() .buildquerybuilder().forentity(design.class).get(); org.apache.lucene.search.query query = qb .keyword() .onfields("designname", "description") .matching(text) .createquery(); org.hibernate.search.fulltextquery hibquery = fulltextsession.createfulltextquery(query, design.class); hibquery.setfirstresult(start); hibquery.setmaxresults(num); @suppresswarnings("unchecked") list<design> designlist = hibquery.list(); (design design : designlist) { hibernate.initialize(design.getdesignimages()); } return designlist;
why hibquery.list().size() smaller hibquery.getresultsize(). because of difference, .setmaxresults() not work properly.
a reason can index , database not in sync @ time of querying. getresultsize
based on lucene query result size whereas list.size()
actual size of materialized (loaded) entities.
Comments
Post a Comment