5.10.4.Final doesn't work with FullTextEntityManager

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 = ...;

// this causes a compilation error

// this causes a runtime error

// 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();

Ok, now it magically works. Whatever. The only issue is that the documentation doesn’t match.

Glad you were able to solve it. I will update the documentation to make it clearer that org.hibernate.search.jpa.Search should be used when you’re working with an entity manager (not a Session).

To anyone with the same stack trace: that error generally means there’s a configuration error somewhere. Either some types are not considered as entity types by Hibernate ORM (in which case they are not even processed by Hibernate Search), or you forgot to add @Indexed annotations on the entities you want to see indexed.