-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: How to rebuild Hibernate Search index to sync with database
PostPosted: Fri May 09, 2008 2:07 pm 
Beginner
Beginner

Joined: Mon Aug 13, 2007 2:37 am
Posts: 22
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:
Code:

@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@Table(name = "Busines")
@Indexed(index="indexes/businesses")
public abstract class AbstractBusinessCbo  implements java.io.Serializable {


    // Fields   
   @Id
   @DocumentId
   @GeneratedValue(strategy = GenerationType.AUTO)
   @Column(name = "BUSINESS_ID", nullable = false)
     private Integer businessId;
     
     @Column(name = "BUSINESS_NAME")
   @Field(index=Index.TOKENIZED)
     private String businessName;
     

     @JoinColumn (name = "BUSINESS_ID")
     @ContainedIn
     @OneToMany(mappedBy="business")
     private Set businessServices = new HashSet(0);
     
     
     @JoinColumn (name = "BUSINESS_ID")
     @ContainedIn
     @OneToMany(mappedBy="business")
     private Set businessAddresses = new HashSet(0);
 
...   



Top
 Profile  
 
 Post subject:
PostPosted: Sat May 10, 2008 7:39 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

you just have to trigger a manual indexing - http://www.hibernate.org/hib_docs/search/reference/en/html_single/#search-batchindex. You can do this at any time. Just call fullTextSession.index
()
on all objects you want to index.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 10, 2008 12:14 pm 
Beginner
Beginner

Joined: Mon Aug 13, 2007 2:37 am
Posts: 22
Thanks for the response. This is a good temporary solution. However, we also need a long time solution.

In one of Emmanuel Bernard's presentation, he mentioned that when using the Hibernate Search indexing approach, the index can easily get out of sync with the database. So, he suggested using this approach:

1) only invoke indexing after inserts/updates have committed, because a DB rollback can make index out of sync.

2) having a batch or JMS queue code that synchronizes the database data and the index.

His presentation did not show how to achieve this batch queue process. So, we are wondering how can we implement this? Are they examples out there that we can use?

Thanks ...in advance!!!


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 11, 2008 10:58 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
Quote:
1) only invoke indexing after inserts/updates have committed, because a DB rollback can make index out of sync.

This is not true, Search does this automatically, you don't have to worry.
Emmanuel was probably explaining what the problem would be if you weren't using Hibernate Search.

Quote:
having a batch or JMS queue code that synchronizes the database data and the index.

JMS is used only if you would like to enable indexing on a dedicated server; the docs explain how to setup this configuration.
the batch code is what is explained if you follow Hardy's link.

so it is Hibernate Search's purpose to keep them in sync,
you should need the batch indexing only for disaster recovering or Application upgrades, or if you disable Search's normal behavior.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 03, 2008 3:54 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
queenHibernate wrote:
Thanks for the response. This is a good temporary solution. However, we also need a long time solution.

In one of Emmanuel Bernard's presentation, he mentioned that when using the Hibernate Search indexing approach, the index can easily get out of sync with the database. So, he suggested using this approach:

1) only invoke indexing after inserts/updates have committed, because a DB rollback can make index out of sync.

2) having a batch or JMS queue code that synchronizes the database data and the index.

His presentation did not show how to achieve this batch queue process. So, we are wondering how can we implement this? Are they examples out there that we can use?

Thanks ...in advance!!!


The point of my pres was to explain how good Hibernate Search is and how it takes care of that for you. I guess I failed in my message ;)

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.