Hibernate 搜索分页 +全文搜索 +标准
我正在尝试使用某些条件进行搜索
FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery(finalQuery, KnowledgeBaseSolution.class).setCriteriaQuery(criteria);
,然后对其进行分页,
//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());
我怀疑 Lucene 返回全文搜索的完整结果而不考虑条件,然后休眠搜索之后应用条件,因此某些页面是空的(按条件过滤后) )
使用某些条件进行 fullTextSearch 的正确方法是什么,是否可以在 lucene 搜索之前应用这些条件?
或者我是否必须使用纯 Lucene(如果是这样,Hibernate Search 的意义何在?)
提前致谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然,您不能将 fullTextSearch 和条件以及分页/排序一起使用。除非你去Lucene级别
链接文本
Apparently you cannot use fullTextSearch and criteria and paging/sorting together. Unless you go to the Lucene level
link text