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.  [ 12 posts ] 
Author Message
 Post subject: Hibernate with Lucene
PostPosted: Sat Oct 04, 2003 8:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Just read the wiki page about Lucene usage with Hibernate. Oddly enough, I just got a requirement to implement some type of search engine and the current lean is toard Lucene.

I've never used Lucene before and need to figure out a way to make operations against Lucene be transactional (my understanding is that it does not support transactional operations.

Not knowing much about Lucene, it seems to me I have two options:
1) update Lucene through JMS, where the JMS feed from the Hibernate interceptor is XA transaction aware;
2) Buffer the updates to Lucene in a class that registers a synch with the transaction manager managing the connection used by hibernate and then apply updates oly when the transaction commits.

#1 risks slowing the operation down, while #2 risks mixed hueristics issues.

Anyone used Lucene in this manner and have a better approach?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 07, 2003 3:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
bump


Top
 Profile  
 
 Post subject: Re: Hibernate with Lucene
PostPosted: Tue Oct 07, 2003 3:54 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
steve wrote:
Just read the wiki page about Lucene usage with Hibernate. Oddly enough, I just got a requirement to implement some type of search engine and the current lean is toard Lucene.

I've never used Lucene before and need to figure out a way to make operations against Lucene be transactional (my understanding is that it does not support transactional operations.

Not knowing much about Lucene, it seems to me I have two options:
1) update Lucene through JMS, where the JMS feed from the Hibernate interceptor is XA transaction aware;
2) Buffer the updates to Lucene in a class that registers a synch with the transaction manager managing the connection used by hibernate and then apply updates oly when the transaction commits.

#1 risks slowing the operation down, while #2 risks mixed hueristics issues.

Anyone used Lucene in this manner and have a better approach?


Are you going to store index in RDBMS ?


Top
 Profile  
 
 Post subject: Re: Hibernate with Lucene
PostPosted: Tue Oct 07, 2003 5:05 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
steve wrote:
#1 risks slowing the operation down, while #2 risks mixed hueristics issues.

If you're in read mostly case, use the first one, it'll be the easiest way. The $100 question is Are you sure to need guaranteed transaction concistency ?
In the #1 case, you're sure to have your message in the failed queue is lucene goes wrong. You're not sure of concistency between DB and Lucene. The concistency is limited to 1 change in DB = 1 message sent and received properly.
Actually it's the same for #2 case, no way to have concistency between Lucene and DB : lucene will always be late.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 07, 2003 5:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Quote:
Are you going to store index in RDBMS

Can you do that with Lucene? I thought Lucene could only utilize the underlying file system for index storage.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 08, 2003 8:26 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
steve wrote:
Quote:
Are you going to store index in RDBMS

Can you do that with Lucene? I thought Lucene could only utilize the underlying file system for index storage.


You can implement RDBMS "file system" yourself and use db server transactions see org.apache.lucene.store.* package, but I do not think it will perform (lusene locks index), most of databases support text search internaly and it must be better to use SQL extensions and procedures.
I use lucene, but my use case is very trivial script. Lucene is good for this use case:

1. export db to text file (if you do not want SQL overhead on transactional system)
2. parse files (or execute SQL on DB directly) to build index
3. copy index to web server (index can contain data too)
4. rename directory with new index

It performs very well, if your change data peridicaly and it must be trivial to implement this kind of script.


Top
 Profile  
 
 Post subject: rollback lucene index changes on rollback
PostPosted: Tue Oct 04, 2005 5:11 pm 
Newbie

Joined: Thu Dec 30, 2004 6:58 pm
Posts: 6
We're using the Interceptor example provided on this site to integrate Lucene with Hibernate in our project. We ran into a situation where we think the Lucene index is getting updated (via onFlushDirty) before Hibernate commits changes to the database. If for some reason Hibernate encounters an error and needs to rollback, the lucene index does not get rolled back. So we have an issue there with keeping the lucene index in synch with the database.
We're looking into it - I'm wondering if anybody else has run into this same type of problem and how/if they resolved it?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 5:04 am 
Beginner
Beginner

Joined: Wed Jan 21, 2004 10:15 am
Posts: 24
Location: Munich, Germany
Hi!

There is a framework called Compass that adresses some of your issues. I have tried it, and it seems quite usable. At least, the support is very good.

http://www.compassframework.org/

Christian


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 9:30 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hibernate Annotations has a integration with lucene, but has the same problem as you right now. I guess I should do the work on a postTransactionCompletionEventListener

But it that case, the changes won't be seen until the tx commit.
To work around that, you need a tx management on top of lucene.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 4:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
steve wrote:
bump


This is against the forum rules. If you continue in this behavior, I will have to ask Christian to ban you.

;-)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 4:57 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
gavin wrote:
steve wrote:
bump


This is against the forum rules. If you continue in this behavior, I will have to ask Christian to ban you.

;-)


Oh, and please consider commerical support. ;-)


Top
 Profile  
 
 Post subject: Re: rollback lucene index changes on rollback
PostPosted: Thu Oct 06, 2005 6:15 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
sflahave wrote:
We're using the Interceptor example provided on this site to integrate Lucene with Hibernate in our project. We ran into a situation where we think the Lucene index is getting updated (via onFlushDirty) before Hibernate commits changes to the database. If for some reason Hibernate encounters an error and needs to rollback, the lucene index does not get rolled back. So we have an issue there with keeping the lucene index in synch with the database.
We're looking into it - I'm wondering if anybody else has run into this same type of problem and how/if they resolved it?


You can update index using commands to undo changes:

class Update extends Command{

Document oldDoc, newDoc;

void execute(){
deleteOldDoc();
insertNewDoc();
}

void undo(){
deleteNewDoc();
insertOldDoc();

}


}

This stuff will not be transactional, but it must solve 99% of problems for text search (store all executed commands in list and call undo for all commands if trasaction fails). I asume you can tolerate some "dirty" data for text search in practice.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 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.