Stop indexing everytime i start the application

Hi Guys,
I have 90 millions records in the database and i do indexing using Hibernate Search in spring boot application .
I want to index data only one time!, Then every time i run the application it looks up the indexed data.
Is there any way to do that ?

Thanks,
Ibrahim

Hibernate Search, by default, persists the index on disk. So there really is no point in reindexing on every startup, if your mapping did not change.

With that in mind, the problem becomes “how to execute the mass indexer only once, not on every startup”. And the answer does not depend on Hibernate Search at all, but on how you trigger mas indexing from Spring Boot.

What I used to do was to add a button to the administration console of my application that triggers mass indexing. The first time I deploy, I open the administration console and click that button. The next times I have to boot the application for whatever reason, I simply do not touch that button. This solution is fairly simple to implement.

I suppose you could find a way to automate the process, but I’m not sure it’s such a good idea: even if your indexes are empty, you may want to start your application without reindexing, just to check something out.

Anyway, as I said, if you want to automate this and need some help, you will need to ask Spring Boot experts how to trigger a task on the first startup of your application only.

1 Like