• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between Lucene IndexWriter.prepareCommit & IndexWriter.commit

 
Aneesh Vijendran
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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]
 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you find prepareCommit method in IndexReader class?? I can't find it in IndexReader documentation...
 
Aneesh Vijendran
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Aneesh Vijendran
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael. You are a star
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic