Hibernate 搜索分页 +全文搜索 +标准

发布于 2024-08-22 16:08:21 字数 686 浏览 2 评论 0原文

我正在尝试使用某些条件进行搜索

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空心↖ 2024-08-29 16:08:21

显然,您不能将 fullTextSearch 和条件以及分页/排序一起使用。除非你去Lucene级别

链接文本

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

link text

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文