I am having an issue whenever I try to manually re-index my data. Currently all interaction is done through a JPA repository, and so when ever we save an object it is reflected in the index as intended. We want to add in manual re-indexing as we use an external ES cluster, and if that ever becomes unavailable we want to be able to re-index only the most recent objects, instead of the 5+ years of data we have.
We get the objects by calling variations of the JPA repository methods, and some custom methods (findById, findCreatedBetween etc).
To get the full text entity manager we are calling org.hibernate.search.jpa.Search.getFullTextEntityManager on an EntityManager instance. We have tried autowiring an EntityManagerFactory to create new EntityManager, and we have tried using the @PersistenceContext annotation within a repository which we then extend from our object repository. Both times when we call fullTextEntityManager.index(object) we get a TransientObjectException “The instance was not associated with this session”.
I appreciate this is a spring specific issue, but if anyone has an idea as to how we can get the correct session/entity manager it would be greatly appreciated, as I am pulling my hair out trying to solve this one!