Hello,
I'm trying to use hibernate-search for searching mongodb entries using an infinispan directory provider for the index on wildfly 10.1.
https://docs.jboss.org/hibernate/stable/ogm/reference/en-US/html_single/?v=5.1#ogm-configuration-jbossmodule did not work for me (module hibernate.search:5.6 not found). I only got the stack running following the example found on:
https://forum.hibernate.org/viewtopic.php?f=31&t=1043482. My current configuration:
POM:
Code:
<version.wildfly>10.1.0.Final</version.wildfly>
<version.wildfly.bom>${version.wildfly}</version.wildfly.bom>
<version.wildfly.hibernate.ogm>5.0.4.Final</version.wildfly.hibernate.ogm>
<version.wildfly.hibernate.orm>5.2.8.Final</version.wildfly.hibernate.orm>
<version.wildfly.infinispan>8.2.5.Final</version.wildfly.infinispan>
...
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-javaee7-with-tools</artifactId>
<version>${version.wildfly.bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>${version.javaee}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-bom</artifactId>
<version>${version.wildfly.hibernate.ogm}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-directory-provider</artifactId>
<version>${version.wildfly.infinispan}</version>
</dependency>
</dependencies>
</dependencyManagement>
...
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>${version.maven.dependency.plugin}</version>
<inherited>false</inherited>
<executions>
<execution>
<id>unpack</id>
<phase>validate</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-orm-modules</artifactId>
<version>${version.wildfly.hibernate.orm}</version>
<classifier>wildfly-10-dist</classifier>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>${jboss.home}/modules</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-modules-wildfly10</artifactId>
<version>${version.wildfly.hibernate.ogm}</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>${jboss.home}/modules</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-as-embedded-modules</artifactId>
<version>${version.wildfly.infinispan}</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>${jboss.home}/modules</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
PU:
Code:
<persistence-unit name="seed" transaction-type="JTA">
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
<jar-file>seed-model.jar</jar-file>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.search.default.directory_provider"
value="infinispan"/
<property name="hibernate.ogm.datastore.provider"
value="mongodb"/>
<property name="hibernate.ogm.datastore.database"
value="seed"/>
</properties>
</persistence-unit>
MANIFEST
Code:
Dependencies: org.hibernate.ogm:5.0 services, org.hibernate.ogm.infinispan:5.0 services, org.hibernate.ogm.mongodb:5.0 services, org.hibernate.search.orm:5.6 services, org.hibernate.search.engine:5.6 services
Now persisting and searching works as long as I don't restart.
The following should re-index the previously persisted:
Code:
@Singleton
@Startup
public class SeedIndexService {
private static final Logger logger = Logger.getLogger(SeedService.class.getName());
private FullTextEntityManager em;
@PostConstruct
public void index() {
try {
logger.info("Starting indexer for Seed Database...");
Long start = System.nanoTime();
this.em.createIndexer().startAndWait();
Long end = System.nanoTime();
logger.info("Finished indexing of Seed Database in " + (end - start) * Math.pow(10, -9) + " seconds.");
} catch (InterruptedException e) {
logger.severe("Exception during indexing of Seed Database: " + e.getMessage());
}
}
@Inject
public void setEntityManager(@SeedDatabase FullTextEntityManager entityManager) {
this.em = entityManager;
}
}
It runs, stops, does not complain but does not index anything...
Finally my questions:
- What could be the reason that the "on the fly" indexer knows how to index and the batch indexer does not?
- Could somebody please provide a working configuration (ogm, search, infinispan, wildfly10.1) with the latest version of ogm?
Thanks!