public int getNumDocs() {
   LuceneIndexReader reader = IndexReaderFactoryUtils.getIndexReader(indexFactory);
   try {
     return reader.numDocs();
   } finally {
     IndexReaderFactoryUtils.releaseIndexReader(indexFactory, reader);
   }
 }
 public boolean hasDeletions() {
   LuceneIndexReader reader = IndexReaderFactoryUtils.getIndexReader(indexFactory);
   try {
     return reader.hasDeletions();
   } finally {
     IndexReaderFactoryUtils.releaseIndexReader(indexFactory, reader);
   }
 }
 public boolean isDeleted(int internalDocumentId) {
   LuceneIndexReader reader = IndexReaderFactoryUtils.getIndexReader(indexFactory);
   try {
     return reader.isDeleted(internalDocumentId);
   } finally {
     IndexReaderFactoryUtils.releaseIndexReader(indexFactory, reader);
   }
 }
 public void undeleteDocuments() {
   LuceneIndexReader reader = IndexReaderFactoryUtils.getIndexReader(indexFactory);
   try {
     reader.undeleteAll();
   } catch (IOException ex) {
     throw new LuceneIndexAccessException("Error during undeleting all documents.", ex);
   } finally {
     IndexReaderFactoryUtils.releaseIndexReader(indexFactory, reader);
   }
 }
 public void deleteDocument(int internalDocumentId) {
   LuceneIndexReader reader = IndexReaderFactoryUtils.getIndexReader(indexFactory);
   try {
     reader.deleteDocument(internalDocumentId);
   } catch (IOException ex) {
     throw new LuceneIndexAccessException("Error during deleting a document.", ex);
   } finally {
     IndexReaderFactoryUtils.releaseIndexReader(indexFactory, reader);
   }
 }
 public void deleteDocuments(Term term) {
   System.out.println("> indexFactory = " + indexFactory);
   LuceneIndexReader reader = IndexReaderFactoryUtils.getIndexReader(indexFactory);
   System.out.println("> reader = " + reader);
   try {
     reader.deleteDocuments(term);
   } catch (IOException ex) {
     throw new LuceneIndexAccessException("Error during deleting a document.", ex);
   } finally {
     IndexReaderFactoryUtils.releaseIndexReader(indexFactory, reader);
   }
 }
  public void updateDocuments(
      Term identifierTerm, DocumentsModifier documentsModifier, Analyzer analyzer) {
    LuceneIndexReader reader = IndexReaderFactoryUtils.getIndexReader(indexFactory);
    LuceneSearcher searcher = reader.createSearcher();
    List updatedDocuments = null;
    try {
      LuceneHits hits = searcher.search(new TermQuery(identifierTerm));
      updatedDocuments = documentsModifier.updateDocuments(hits);
    } catch (Exception ex) {
      throw new LuceneIndexAccessException("Error during updating a document.", ex);
    } finally {
      SearcherFactoryUtils.closeSearcher(searcher);
      IndexReaderFactoryUtils.releaseIndexReader(indexFactory, reader);
    }

    deleteDocuments(identifierTerm);
    addDocuments(updatedDocuments, analyzer);
  }