本文介绍了加入具有条件查询限制的休眠搜索查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道您如何将以下两个查询结合在一起.
I'm wondering how you would join the following two queries together.
标准条件查询
Criteria result1 = session.createCriteria(Store.class).add(Restrictions.eq("department.name", category));
和FullTextSearch
and a FullTextSearch
QueryBuilder queryBuilder = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(Store.class).get();
Query luceneQuery = queryBuilder.keyword().onFields("productTitle").matching(keyword).createQuery();
// wrap Lucene query in a javax.persistence.Query
org.hibernate.Query fullTextQuery = fullTextSession.createFullTextQuery(luceneQuery, Store.class);
fullTextQuery.setMaxResults(15);
fullTextQuery.setFirstResult(0);
我通过URL加上关键字参数来传递其他参数,我不想完全依靠关键字搜索.有人知道如何使它们一起工作吗?
I pass in additional parameters through the URL plus a keyword parameter, I do not want to fully rely on keyword search. Does anybody know how to make these work together?
谢谢.
推荐答案
此问题的解决方案是使用可以在此处找到的过滤器.
The solution to this problem was to use a Filter which can be found here.
http: //docs.jboss.org/hibernate/search/4.4/reference/zh-CN/html/search-query.html#query-filter
这篇关于加入具有条件查询限制的休眠搜索查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!