如何在java中使用hibernate进行多面搜索? [英] How to do Multi Faceted search using hibernate in java?

查看:130
本文介绍了如何在java中使用hibernate进行多面搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Hibernate 4和lucene 3.6。我有一个与方面计数相关的要求。
在我的要求中,我有一个实体产品。实体产品有一些属性,例如id,颜色,品牌。

现在我的要求是我想要在多维中获取此实体的方面数,红色(彩色)耐克(品牌)服饰。所以举个例子。我有以下产品实体保存在我的数据库中。



id品牌颜色

1锐步红色
2锐步黑色

3 reebok绿色

4李红色
5李黑色
6李黑色

现在我想让我的代码在这种情况下获取至少两个参数(即firstGroupBy,secondGroupBy),它们是品牌和颜色,并返回如下结果



reebok(3)

锐步红(1)

锐步黑(1)

reebok green(2)

Lee(3)

Lee red(1)

Lee black(2)



在hibernate 4中可以做到这一点吗?如果是,那我该怎么做? $ b

http ://www.hascode.com/2012/03/hibernate-search-faceting-discrete-and-range-faceting-by-example/

希望它有帮助


I am using Hibernate 4 along with lucene 3.6. I have a requirement related to facet count. In my requirement I have an entity "Product". Entity "Product" has some property for example id, color, brand.

Now my requirement is that I want to get facet count for this entity in multidimension, get count for red(color) nike(brand) apparel.

So take a example. I have following product entities saved in my database.

id brand color
1 reebok red
2 reebok black
3 reebok green
4 Lee red
5 Lee black
6 Lee black

Now I want my code to take atleast two parameters(i.e. firstGroupBy, secondGroupBy) which are "brand" and "color" in this case and return results as below

reebok(3)
reebok red(1)
reebok black(1)
reebok green(2)
Lee(3)
Lee red(1)
Lee black(2)

Is it possible to do it in hibernate 4? If yes then how can I do this?

解决方案

Following url explains how to do

http://www.hascode.com/2012/03/hibernate-search-faceting-discrete-and-range-faceting-by-example/

Hope it helps

这篇关于如何在java中使用hibernate进行多面搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆