Java Mailing List Archive

http://www.java2.5341.com/

Home » java-user.lucene »

Using DeletionPolicy to roll back to previous commit point

mark harwood

2008-11-11


Author LoginPost Reply
Probably a question for Mike M.
Is it possible/sensible to use IndexDeletionPolicy to remove the *newest* commit points (as opposed to the usual scenario of deleting old commit points).


I experimented with this:

  class RollbackDeletionPolicy implements IndexDeletionPolicy
  {
    public void onCommit(List commits) throws IOException {
    }

    public void onInit(List commits) throws IOException {
       IndexCommit commit=(IndexCommit)commits.get(commits.size()-1);
       commit.delete();        
    }    
  }

....

And opening and closing a writer...

void myRollback()
{
    IndexWriter w=new IndexWriter(dir,analyzer, new RollbackDeletionPolicy(),
                        MaxFieldLength.UNLIMITED);
    w.close();
}


This mostly worked but segments.gen was not updated to reflect the regression in the list of active segments. Is there an API somewhere to reinstate the segments.gen file?
I assume I would also need to take care to close all readers before attempting a rollback-to-earlier-commitpoint.

Cheers,
Mark




---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@(protected)
For additional commands, e-mail: java-user-help@(protected)

©2008 java2.5341.com - Jax Systems, LLC, U.S.A.