如何在Hibernate Search中删除所有重复的结果? [英] How to remove all the duplicate results in Hibernate Search?
问题描述
我正在将Infinispan与6.0.2和Hibernate Search 4.4.0一起使用.
I'm using Infinispan with 6.0.2 with Hibernate Search 4.4.0.
首先,在执行
CacheQuery cq = SearchManager.getQuery(query,Hibernate.class).projection("id");
我使用 cq.list()
来获取"id".
I use the cq.list()
to get "id".
但是现在结果的数量达到300.000,由于设计了fo DB(更改值),重复ID几乎为29,000.
But now the number of results reaches 300.000, because of the designing fo DB(cant change), the duplicate id is almost 29,000.
我写这个是为了得到"id":
I wrote this to get "id":
for(int i=0;i<listObject.size();i++)
{
Object[] rdf = (Object[])listObject.get(i);
if(!result.contains((String) rdf[0]))
result.add((String) rdf[0]);
}
但是,即使我并行处理这部分,也需要很长时间.
But even if I parallel this part, it also takes a long time.
像SQL中的 DISTINCT 一样,是否有功能在Hibernate中删除查询的重复ID?
Does there is a function to remove duplicate id for the query in Hibernate like the DISTINCT does in SQL?
推荐答案
setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)使用唯一的.
setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) use the distinct .
这篇关于如何在Hibernate Search中删除所有重复的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!