'How to do programmatic indexing with infinispan-13?
How is it possible to do programmatic definition of indexes for pojos with infinispan-13? According to the online documentation here: the code hasn't changed. However, the classes referred to no longer exist in hibernate-6, which is used by infinispan-13.
Note that it is not possible to use annotations on the pojo class to be indexed because it is used elsewhere by code that cannot have any dependency on infinispan or hibernate etc, so I need to pursue the programmatic route that used to work in infinispan-11.
This is the code that currently works in infinispan-11:
EmbeddedCacheManager cacheManager = new DefaultCacheManager(new GlobalConfigurationBuilder().jmx().build());
SearchMapping mapping = new SearchMapping();
mapping.entity(MyData.class).indexed().property("expiry", ElementType.FIELD).field();
Properties properties = new Properties();
properties.put(Environment.MODEL_MAPPING, mapping);
properties.put("hibernate.search.default.indexBase", "/some/path");
Configuration dcc = cacheManager.getDefaultCacheConfiguration();
ConfigurationBuilder b = new ConfigurationBuilder();
if (dcc != null)
b = b.read(dcc);
b.indexing().addIndexedEntity(MyData.class).withProperties(properties);
Solution 1:[1]
I also use Infinispan 13.0.6. This configuration works just fine.
Here is my configuration:
ConfigurationBuilder builder = new ConfigurationBuilder();
Properties p = new Properties();
try(Reader r = new FileReader("/srv/ws-emporium/hotrod-client.properties")) {
p.load(r);
builder.withProperties(p);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
remoteCacheManager = new RemoteCacheManager(builder.build());
cache = remoteCacheManager.getCache("teste15Fev22");
My properties file content:
infinispan.client.hotrod.server_list = server1:11222;server2:11322
infinispan.client.hotrod.auth_username=admin
infinispan.client.hotrod.auth_password=password
infinispan.client.hotrod.connection_pool.max_active = 10
infinispan.client.hotrod.connection_pool.exhausted_action = WAIT
infinispan.client.hotrod.connection_pool.max_wait = 1
infinispan.client.hotrod.connection_pool.min_idle = 20
infinispan.client.hotrod.connection_pool.min_evictable_idle_time = 300000
infinispan.client.hotrod.connection_pool.max_pending_requests = 20
infinispan.client.hotrod.marshaller=org.infinispan.commons.marshall.JavaSerializationMarshaller
infinispan.client.hotrod.java_serial_allowlist=.*
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
