コード例 #1
0
 public int getNumDocs() {
   LuceneIndexReader reader = IndexReaderFactoryUtils.getIndexReader(indexFactory);
   try {
     return reader.numDocs();
   } finally {
     IndexReaderFactoryUtils.releaseIndexReader(indexFactory, reader);
   }
 }
コード例 #2
0
 public boolean hasDeletions() {
   LuceneIndexReader reader = IndexReaderFactoryUtils.getIndexReader(indexFactory);
   try {
     return reader.hasDeletions();
   } finally {
     IndexReaderFactoryUtils.releaseIndexReader(indexFactory, reader);
   }
 }
コード例 #3
0
 public boolean isDeleted(int internalDocumentId) {
   LuceneIndexReader reader = IndexReaderFactoryUtils.getIndexReader(indexFactory);
   try {
     return reader.isDeleted(internalDocumentId);
   } finally {
     IndexReaderFactoryUtils.releaseIndexReader(indexFactory, reader);
   }
 }
コード例 #4
0
 public Object read(ReaderCallback callback) {
   LuceneIndexReader reader = IndexReaderFactoryUtils.getIndexReader(indexFactory);
   try {
     return callback.doWithReader(reader);
   } catch (Exception ex) {
     throw new LuceneIndexAccessException("Error during using the IndexReader.", ex);
   } finally {
     IndexReaderFactoryUtils.releaseIndexReader(indexFactory, reader);
   }
 }
コード例 #5
0
 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);
   }
 }
コード例 #6
0
 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);
   }
 }
コード例 #7
0
 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);
   }
 }
コード例 #8
0
  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);
  }