Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Using Hibernate Search + Lusql Index together
PostPosted: Thu Apr 26, 2012 8:30 am 
Newbie

Joined: Thu Apr 26, 2012 7:52 am
Posts: 1
Hi All,

We are using lusql command to generate index for the data already present in DB
and then we use hibernate search to add/update/delete for any other transactions.

The issue what we are facing is, when ever we are trying to update the records that generated using lusql, Hibernate search is making a new entry for that record in the index, so, entries are getting duplicated.

Please any 1 can tel me, ca we go with this approch of using lusql generated index + hibernate also.
& how to avoid this duplicate entries.

Any suggestion is very much apprciated.

Thanks In Advance


Top
 Profile  
 
 Post subject: Re: Using Hibernate Search + Lusql Index together
PostPosted: Mon Apr 30, 2012 7:12 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2296
Location: Third rock from the Sun
Hi,
Hibernate Search will know if it needs to update an index document or insert a new one depending on the event type it recives from Hibernate Core.

So a first requirement is to make sure Hibernate Core knows if is updating an existing database record rather than inserting a new one - I guess this is already the case as otherwise you would have conflicts on primary keys, so I'm assuming this first step is resolved.

The second step is to make sure that Hibernate Search understands an existing document is logically "the same" as one it's creating, so that it will remove the old version rather than only inserting the new version. For this to work you have to make sure the existing Document in the index contains the two fields Hibernate Search uses to identify a document:
the field _hibernate_class needs to contain the class name (this is a constant field name), and the field you mapped as @Id or @DocumentId must contain the identifier of the entity in it's string form: this field name is configurable in your mapping (so it must match the name you have given it), and the value string should also match the format being used by Hibernate Search.

I guess the simplest way to look at this format is to check with Luke which values you have in the index, then make sure that LuSQL includes the fields as Hibernate Search expects them, and/or define a StringBridge in Hibernate Search to customize the format of the ID to make sure it matches the format used by LuSQL.

Alternatively, you could use the MassIndexer provided by Hibernate Search to build the initial index instead of LuSQL. I'm new to LuSQL, is there some benefit of using it over the MassIndexer we provided?

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


Top
 Profile  
 
 Post subject: Re: Using Hibernate Search + Lusql Index together
PostPosted: Wed May 09, 2012 11:44 pm 
Newbie

Joined: Thu May 03, 2012 10:20 pm
Posts: 4
Thank you to share.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 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.