开发者

Hibernate Search Paging + FullTextSearch + Criteria

开发者 https://www.devze.com 2022-12-20 15:02 出处:网络
I am trying to do a search with some criteria FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery(finalQuery, KnowledgeBaseSolution.class).setCriteriaQuery(criteria);

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开发者_JS百科, 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


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

link text

0

精彩评论

暂无评论...
验证码 换一张
取 消