lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mark harwood <markharw...@yahoo.co.uk>
Subject Using DeletionPolicy to roll back to previous commit point
Date Tue, 11 Nov 2008 10:27:24 GMT
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@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message