• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to rebuild Hibernate Search index to sync with database

 
Nina Anderson
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I accidentally deleted my Hibernate Search index file on my local server. So, I'm wondering how I can rebuild index to sync with the data in the database?

Here's a sample of my entity annotation:


Please ...HeLP!!!
 
Abiodun Adisa
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nina Anderson:
Hi guys,

I accidentally deleted my Hibernate Search index file on my local server. So, I'm wondering how I can rebuild index to sync with the data in the database?

Here's a sample of my entity annotation:


Please ...HeLP!!!


First Write an Hibernate Code to retrieve all the Data you want indexed next instantiate a FullTextSession and Iterate through the retrieved Set ...

FullTextSession fullTextSession = Search.createFullTextSession(session);
Transaction tx = fullTextSession.beginTransaction();
List<AbstractBusinessCbo > abstractBusinessCboS = jAbstractBusinessCbo DAO.findAllData();

for (AbstractBusinessCbo abstractBusinessCbo : abstractBusinessCboS ) {
fullTextSession.index(abstractBusinessCbo );
}
}
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!