Reputation: 35
With 2 other students, we are working on a project. The architecture is the following one :
A java service, using a web crawler to get informations on website and storing the results in is own database. We are not using Hibernate on this project.
A J2E website, using maven/spring/hibernate (code first)
With a scheduled task, we are inserting the results from the web crawler database to the website database.
Of course, we'd like to have a fast research on this results on the website ! So I was thinking about using HibernateSearch, which seems to be an amazing tool !
However, I'm not sure I can use it in my case : As much as I know, Hibernate-search is updating the indexes on (hibernate)transactions, and since the inserts are not done throught hiberate, I'm wondering if it will still work (does hibernate will notice database transactions ?) , and if it's not, if there is any tricks to force the update by the service !
Note : I know there is an instruction to create the indexes :
FullTextSession fullTextSession = Search.getFullTextSession(session);
fullTextSession.createIndexer().startAndWait()
but I dont really want to drop/create the indexes everytime I do my inserts.
Upvotes: 0
Views: 263
Reputation: 6107
Hibernate Search can not listen to internal events from the database, it will only be able to update indexes automatically provided you perform your insers using Hibernate ORM.
Some Hibernate Search users in a similar scenario will simply trigger the MassIndexer
periodically (e.g. every night). Depending on your use case this might be fine, for example if your web application is a web shop people are normally ok for new items to show up in the search results with some delay after being inserted.
If that doesn't work for your use case, you have two alternatives:
A "manual" index is performed by loading the new element via Hibernate ORM and then invoking FullTextSession.index( entity )
.
Upvotes: 3