3 Replies Latest reply on Jun 17, 2014 3:07 AM by abey4315266

    How to remove all the duplicate results in Hibernate Search with Infinispan?

    abey4315266

      I'm using Infinispan  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" (not the unique 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. (The value for each id is correct)

      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.

      I saw there is a method called setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) in Hibernate, but I dont know how to do it in Infinispan.

      Or is there a method in Infinispan doing the same thing like 'DISTINCT' of SQL??