• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Difference between Lucene IndexWriter.prepareCommit & IndexWriter.commit

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Michael. You are a star
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic