How to remove all the duplicate results in Hibernate Search?

 ̄綄美尐妖づ 提交于 2021-02-20 09:31:13

问题


I'm using Infinispan with 6.0.2 with Hibernate Search 4.4.0.

In the begining, after I execute a query like

CacheQuery cq = SearchManager.getQuery(query,Hibernate.class).projection("id");

I use the cq.list() to get "id".

But now the number of results reaches 300.000, because of the designing fo DB(cant change), the duplicate id is almost 29,000.

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.

Does there is a function to remove duplicate id for the query in Hibernate like the DISTINCT does in SQL?


回答1:


setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) use the distinct .



来源:https://stackoverflow.com/questions/24179103/how-to-remove-all-the-duplicate-results-in-hibernate-search

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!