The online documention at doesn’t work, for 5.10.4.Final, when using the JPA entity manager example code.
org.hibernate.search.Search.getFullTextEntityManager(EntityManager) method does not exist in 5.10.4.Final!
I tried instead to use
org.hibernate.search.jpa.Search.getFullTextEntityManager(EntityManager), and that compiles, but I get this runtime error when calling createIndexer():
java.lang.IllegalArgumentException: HSEARCH000349: Some of the specified entity types (‘class java.lang.Object’) are not indexed, nor is any of their subclasses.
at org.hibernate.search.batchindexing.impl.MassIndexerImpl.toRootEntities(MassIndexerImpl.java:104)
at org.hibernate.search.batchindexing.impl.MassIndexerImpl.(MassIndexerImpl.java:64)
at org.hibernate.search.batchindexing.impl.DefaultMassIndexerFactory.createMassIndexer(DefaultMassIndexerFactory.java:33)
at org.hibernate.search.impl.FullTextSessionImpl.createIndexer(FullTextSessionImpl.java:175)
createIndexer() works perfectly, if I use a Hibernate session.
Here’s some condensed code to illustrate the createIndexer() errors:
EntityManager entityManager = ...;
entityManager.getTransaction().begin();
// this causes a compilation error
org.hibernate.search.Search.getFullTextEntityManager(entityManager).createIndexer();
// this causes a runtime error
org.hibernate.search.jpa.Search.getFullTextEntityManager(entityManager).createIndexer();
// this works perfectly
org.hibernate.search.Search.getFullTextSession((Session) entityManager.getDelegate()).createIndexer();
//and correctly builds the Lucene indexes if I call startAndWait()
org.hibernate.search.Search.getFullTextSession((Session) entityManager.getDelegate()).createIndexer().startAndWait();