Hibernate Search Paging + FullTextSearch + Criteria
- by Roy Chan
I am trying to do a search with some criteria
FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery(finalQuery, KnowledgeBaseSolution.class).setCriteriaQuery(criteria);
and then page it
//Gives me around 700 results
result.setResultCount(fullTextQuery.getResultSize());
//Some pages are empty
fullTextQuery.setFirstResult(( (pageNumber - 1) * pageSize ));
fullTextQuery.setMaxResults( pageSize );
result.setResults(fullTextQuery.list());
I suspect Lucene return full result of the full text search without taking the criteria into account and then hibernate search applies the criteria after, therefore some page are empty (after filtering by criteria)
What is proper way to do fullTextSearch with some criteria, is it possible to apply the criteria before the lucene search?
Or do I have to use pure Lucene (if so what's the point of Hibernate Search?)
Thanks in advance