//Rolls back index to a chosen ID
private void RollBackLast(int id)
{
// System.out.println("Attempting to rollback to "+id);
System.String ids = "-" + id;
IndexCommit last = null;
System.Collections.ICollection commits = IndexReader.ListCommits(dir);
for (System.Collections.IEnumerator iterator = commits.GetEnumerator(); iterator.MoveNext();)
{
IndexCommit commit = (IndexCommit)iterator.Current;
System.Collections.Generic.IDictionary <string, string> ud = commit.GetUserData();
if (ud.Count > 0)
{
if (((System.String)ud["index"]).EndsWith(ids))
{
last = commit;
}
}
}
if (last == null)
{
throw new System.SystemException("Couldn't find commit point " + id);
}
IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(), new RollbackDeletionPolicy(this, id), MaxFieldLength.UNLIMITED, last);
System.Collections.Generic.IDictionary <string, string> data = new System.Collections.Generic.Dictionary <string, string>();
data["index"] = "Rolled back to 1-" + id;
w.Commit(data);
w.Close();
}