Index problem object not found after change
smoers Jun 9, 2015 7:45 AMHello,
I have created a cache with 500 objects. When I send a search on object content everything works correctly, the object is found.
If I read a specific object into the cache and that I change the value of one parameter of this one, then I refill this one into the cache. This new value can not be use to retrieve the specific object.
Can you indicate to the correct method ?
Many thanks,
Serge
import java.lang.annotation.ElementType; import java.util.Hashtable; import java.util.Properties; import java.util.UUID; import java.util.Map.Entry; import org.apache.lucene.search.Query; import org.hibernate.search.Environment; import org.hibernate.search.cfg.SearchMapping; import org.hibernate.search.query.dsl.QueryBuilder; import org.infinispan.Cache; import org.infinispan.configuration.cache.Configuration; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.manager.DefaultCacheManager; import org.infinispan.manager.EmbeddedCacheManager; import org.infinispan.query.CacheQuery; import org.infinispan.query.ResultIterator; import org.infinispan.query.SearchManager; import org.infinispan.query.Search; public class Inf_14 { public static void main(String[] args) { // TODO Auto-generated method stub EmbeddedCacheManager manager = new DefaultCacheManager(); ConfigurationBuilder cb = new ConfigurationBuilder(); SearchMapping mapping = new SearchMapping(); mapping.entity(AuthorInfinispan.class).indexed().providedId() .property("lastname", ElementType.METHOD) .property("firstname", ElementType.METHOD) .property("authoralias", ElementType.METHOD); mapping.entity(CycleInfinispan.class).indexed().providedId() .property("cycletitle", ElementType.METHOD); mapping.entity(BookInfinispan.class).indexed().providedId() .property("title", ElementType.METHOD) .property("style", ElementType.METHOD); Properties properties = new Properties(); properties.put(Environment.MODEL_MAPPING, mapping); //properties.put("hibernate.search.default.directory_provide", "filesystem"); //properties.put("hibernate.search.default.indexBase", "D:/infinispan/Indexes/"); Configuration c = cb .indexing() .enable() .indexLocalOnly(true) .withProperties(properties) .persistence() .passivation(false) .addSingleFileStore() .preload(true) .shared(false) .fetchPersistentState(true) .ignoreModifications(false) .purgeOnStartup(false) .location("D:/infinispan") .build(); manager.defineConfiguration("book012015", c); Cache<UUID, IAuthor> cache = manager.getCache("book012015"); SearchManager sm = Search.getSearchManager(cache); IAuthor authorch = cache.get(UUID.fromString("09586ce5-5763-471d-bbca-30b7cf78712e")); authorch.setFirstName("TEST"); cache.put(authorch.getID(), authorch); sm.getMassIndexer().start(); QueryBuilder qb = sm.buildQueryBuilderForClass(AuthorInfinispan.class).get(); Query q = qb.keyword().wildcard().onField("firstname").matching("TEST*").createQuery(); CacheQuery cq = sm.getQuery(q, AuthorInfinispan.class); System.out.println(cq.getResultSize()); ResultIterator it = cq.iterator(); while(it.hasNext()){ IAuthor author = (IAuthor) it.next(); System.out.println("Key : " + author.getID()); System.out.println("Author : " + author.getFirstName() + " " + author.getLastName()); System.out.println("Date de création : " + author.getCreationDate()); System.out.println("Nbr de Cycle : " + author.getListCycle().size()); System.out.println("Site Web : " + author.getWebSite()); System.out.println("Born Date : " + author.getBornDate()); Hashtable<UUID, ICycle> listcycle = author.getListCycle(); for(Entry<UUID, ICycle> entrycycle : listcycle.entrySet()){ ICycle cycle = entrycycle.getValue(); System.out.println("--Cycle : " + cycle.getCycleTitle()); Hashtable<UUID, IBook> listbook = cycle.getListBook(); for(Entry<UUID, IBook> entrybook : listbook.entrySet()){ IBook book = entrybook.getValue(); System.out.println("----Book : " + book.getTitle()); } } System.out.println("-------------------------------------------------------------------"); } it.close(); cache.stop(); manager.stop(); } }
juin 09, 2015 1:26:47 PM org.infinispan.factories.GlobalComponentRegistry start
INFO: ISPN000128: Infinispan version: Infinispan 'Infinium' 6.0.0.Final
juin 09, 2015 1:26:49 PM org.infinispan.query.impl.LifecycleManager cacheStarting
INFO: ISPN014003: Registering Query interceptor
juin 09, 2015 1:26:49 PM org.hibernate.search.Version <clinit>
INFO: HSEARCH000034: Hibernate Search 4.4.0.Final
juin 09, 2015 1:26:49 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
juin 09, 2015 1:26:49 PM org.hibernate.search.impl.ConfigContext getLuceneMatchVersion
WARN: HSEARCH000075: Configuration setting hibernate.search.lucene_version was not specified, using LUCENE_CURRENT.
juin 09, 2015 1:26:51 PM org.infinispan.transaction.lookup.GenericTransactionManagerLookup useDummyTM
WARN: ISPN000104: Falling back to DummyTransactionManager from Infinispan
juin 09, 2015 1:26:51 PM org.infinispan.jmx.CacheJmxRegistration start
INFO: ISPN000031: MBeans were successfully registered to the platform MBean server.
juin 09, 2015 1:26:51 PM org.infinispan.jmx.CacheJmxRegistration start
INFO: ISPN000031: MBeans were successfully registered to the platform MBean server.
juin 09, 2015 1:26:53 PM org.infinispan.query.impl.massindex.DefaultMassIndexerProgressMonitor printStatusMessage
INFO: HSEARCH000030: 50 documents indexed in 33 ms
juin 09, 2015 1:26:53 PM org.infinispan.query.impl.massindex.DefaultMassIndexerProgressMonitor printStatusMessage
INFO: HSEARCH000030: 100 documents indexed in 51 ms
juin 09, 2015 1:26:53 PM org.infinispan.query.impl.massindex.DefaultMassIndexerProgressMonitor printStatusMessage
INFO: HSEARCH000030: 150 documents indexed in 67 ms
juin 09, 2015 1:26:53 PM org.infinispan.query.impl.massindex.DefaultMassIndexerProgressMonitor printStatusMessage
INFO: HSEARCH000030: 200 documents indexed in 80 ms
juin 09, 2015 1:26:53 PM org.infinispan.query.impl.massindex.DefaultMassIndexerProgressMonitor printStatusMessage
INFO: HSEARCH000030: 250 documents indexed in 91 ms
juin 09, 2015 1:26:53 PM org.infinispan.query.impl.massindex.DefaultMassIndexerProgressMonitor printStatusMessage
INFO: HSEARCH000030: 300 documents indexed in 104 ms
juin 09, 2015 1:26:53 PM org.infinispan.query.impl.massindex.DefaultMassIndexerProgressMonitor printStatusMessage
INFO: HSEARCH000030: 350 documents indexed in 114 ms
juin 09, 2015 1:26:53 PM org.infinispan.query.impl.massindex.DefaultMassIndexerProgressMonitor printStatusMessage
INFO: HSEARCH000030: 400 documents indexed in 125 ms
juin 09, 2015 1:26:53 PM org.infinispan.query.impl.massindex.DefaultMassIndexerProgressMonitor printStatusMessage
INFO: HSEARCH000030: 450 documents indexed in 143 ms
juin 09, 2015 1:26:54 PM org.infinispan.query.impl.massindex.DefaultMassIndexerProgressMonitor printStatusMessage
INFO: HSEARCH000030: 500 documents indexed in 168 ms
Result