views:

171

answers:

1

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

A: 

Apparently you cannot use fullTextSearch and criteria and paging/sorting together. Unless you go to the Lucene level

link text

Roy Chan