This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes Difference between Lucene IndexWriter.prepareCommit & IndexWriter.commit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Difference between Lucene IndexWriter.prepareCommit & IndexWriter.commit" Watch "Difference between Lucene IndexWriter.prepareCommit & IndexWriter.commit" New topic
Author

Difference between Lucene IndexWriter.prepareCommit & IndexWriter.commit

Aneesh Vijendran
Ranch Hand

Joined: Jun 29, 2008
Posts: 125
Hi Michael, Erik Hatcher, and Otis,

Whats the difference between IndexReader's prepareCommit & commit method?

Where should be each called or when?

Cheers
Aneesh

[Edit: Fixed IndexWriter in subject - Ankit]


Cheers
Aneesh
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Where did you find prepareCommit method in IndexReader class?? I can't find it in IndexReader documentation...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Aneesh Vijendran
Ranch Hand

Joined: Jun 29, 2008
Posts: 125
Where did you find prepareCommit method in IndexReader class?? I can't find it in IndexReader documentation...


Opps..Typo..it's IndexWriter


http://lucene.apache.org/java/2_4_0/api/org/apache/lucene/index/IndexWriter.html#prepareCommit%28%29
Michael McCandless
author
Greenhorn

Joined: Jul 11, 2010
Posts: 20
prepareCommit lets you do a 2-phased commit with Lucene and some other transactional resource(s).

Ie, you first call .prepareCommit in Lucene (and similarly in your other resources), which does nearly all the work required for a commit but does not in fact make the changes visible in the index.

If any resources hit an error during this phase, you can then call .rollback to remove all the changes.

Else, you then call .commit to make the change visible.

If you don't call .prepareCommit yourself externally, ie just call .commit, then internally Lucene will call .prepareCommit and then commit.


Lucene in Action, 2nd Edition
(http://manning.com/lucene)
Aneesh Vijendran
Ranch Hand

Joined: Jun 29, 2008
Posts: 125
Thanks Michael. You are a star
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between Lucene IndexWriter.prepareCommit & IndexWriter.commit
 
Similar Threads
wht is difference between j2ee&jee
Technology vs framework
Difference between Object and Component
refrence instance and object ?
length and size