2 Replies Latest reply on Jan 11, 2016 5:16 AM by wdfink

    Infinispan query doesn't find all records, just some of them

    vero.katos

      When I debug my application code, I clearly see that all records in the cache object org.infinispan.Cache, but when I use infinispan query, it doesn't find all of them, just some of them! Here is my configuration:


      infinispan.version: 5.3.0.Final

      infinispan-query.version: 5.3.0.Final
      infinispan.lucene.directory.version: 5.3.0.Final
      hibernate.version: 4.3.5.Final

       

      Cache configuration:

       

      Configuration c = new ConfigurationBuilder()

        .read(dcc)
         .indexing()

        .enable()

        .indexLocalOnly(true)//.withProperties(properties)
         .storeAsBinary().enable()

        .build();



      Entity abstract class:


      @Indexed
      @Transformable(transformer = DefaultTransformer.class)

      public abstract class AbstractEntity  {

       

         private String field1;

         private String field2;

         @Field(index = Index.YES, analyze = Analyze.YES)

         protected Long field3;

      }


      Implementation:


      @Indexed
      public class Entity extends AbstractEntity {

       

        private String field3;

        public Entity() {

        }

      }

       

      I do search like this:

       

      @Override
      public Entity findByPrimaryKey(Long primaryKey) {

         SearchManager searcherManager = Search.getSearchManager(getCache()); //I CAN SEE IN DEBUG MODE THAT THIS CACHE OBJECT HAS ALL ENTITIES I NEED
         QueryBuilder queryBuilder = searcherManager.buildQueryBuilderForClass(Entity.class).get();

         Query luceneQuery =

             queryBuilder.keyword().onField("field3").matching(primaryKey).createQuery();

         CacheQuery cacheQuery = searcherManager.getQuery(luceneQuery, Entity.class);

         List<?> result = cacheQuery.list();

         return (Order) cacheQuery.list().get(0);
      }

       

      as a result it returns some entities and for some it returns null, but they are in the cache. is it a problem of the index? should I upgrade infinispan? is there any workaround or I did something wrong?

       

      Thanks.