public static CheckIndex.Status CheckIndex(Directory dir, bool crossCheckTermVectors) { ByteArrayOutputStream bos = new ByteArrayOutputStream(1024); CheckIndex checker = new CheckIndex(dir); checker.CrossCheckTermVectors = crossCheckTermVectors; checker.InfoStream = new StreamWriter(bos, Encoding.UTF8); CheckIndex.Status indexStatus = checker.DoCheckIndex(null); if (indexStatus == null || indexStatus.Clean == false) { Console.WriteLine("CheckIndex failed"); checker.FlushInfoStream(); Console.WriteLine(bos.ToString()); throw RuntimeException.Create("CheckIndex failed"); } else { if (LuceneTestCase.UseInfoStream) { checker.FlushInfoStream(); Console.WriteLine(bos.ToString()); } return(indexStatus); } }
//setIndexReaderSearcher(); public virtual void CheckClean() { try { dir = FSDirectory.Open(indexDir); CheckIndex checkIndex = new CheckIndex(dir); CheckIndex.Status status = checkIndex.CheckIndex(); System.Diagnostics.Debug.Assert((status.clean), "index is not clean"); dir.Close(); } catch (IOException e) { throw new Exception(e); } }