예제 #1
0
 public void undelete() {
   // 使用IndexReader进行恢复
   try {
     IndexReader reader = IndexReader.open(directory, false);
     // 恢复时,必须把IndexReader的只读(readOnly)设置为false
     reader.undeleteAll();
     reader.close();
   } catch (CorruptIndexException e) {
     e.printStackTrace();
   } catch (StaleReaderException e) {
     e.printStackTrace();
   } catch (LockObtainFailedException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
예제 #2
0
 /** 恢复索引 */
 public void undelete() {
   IndexReader reader = null;
   try {
     reader = IndexReader.open(directory, false);
     // 恢复时,必须把indexreader的只读(readonly)设为false
     reader.undeleteAll();
   } catch (CorruptIndexException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   } finally {
     if (reader != null)
       try {
         reader.close();
       } catch (IOException e) {
         e.printStackTrace();
       }
   }
 }
 /** @see LuceneIndexReader#undeleteAll() */
 public void undeleteAll() throws IOException {
   indexReader.undeleteAll();
 }