コード例 #1
0
 public Object write(WriterCallback callback) {
   LuceneIndexWriter writer = IndexWriterFactoryUtils.getIndexWriter(indexFactory);
   try {
     return callback.doWithWriter(writer);
   } catch (Exception ex) {
     throw new LuceneIndexAccessException("Error during using the IndexWriter.", ex);
   } finally {
     IndexWriterFactoryUtils.releaseIndexWriter(indexFactory, writer);
   }
 }
コード例 #2
0
 public void optimize() {
   LuceneIndexWriter writer = IndexWriterFactoryUtils.getIndexWriter(indexFactory);
   try {
     writer.optimize();
   } catch (IOException ex) {
     throw new LuceneIndexAccessException("Error during optimize the index.", ex);
   } finally {
     IndexWriterFactoryUtils.releaseIndexWriter(indexFactory, writer);
   }
 }
コード例 #3
0
 public void addIndexes(Directory[] directories) {
   LuceneIndexWriter writer = IndexWriterFactoryUtils.getIndexWriter(indexFactory);
   try {
     writer.addIndexes(directories);
   } catch (IOException ex) {
     throw new LuceneIndexAccessException("Error during adding indexes.", ex);
   } finally {
     IndexWriterFactoryUtils.releaseIndexWriter(indexFactory, writer);
   }
 }
コード例 #4
0
 public void addDocument(Document document, Analyzer analyzer) {
   LuceneIndexWriter writer = IndexWriterFactoryUtils.getIndexWriter(indexFactory);
   try {
     doAddDocument(writer, document, null);
   } catch (IOException ex) {
     throw new LuceneIndexAccessException("Error during adding a document.", ex);
   } finally {
     IndexWriterFactoryUtils.releaseIndexWriter(indexFactory, writer);
   }
 }
コード例 #5
0
 public void addDocuments(List documents, Analyzer analyzer) {
   LuceneIndexWriter writer = IndexWriterFactoryUtils.getIndexWriter(indexFactory);
   try {
     for (Iterator i = documents.iterator(); i.hasNext(); ) {
       Document document = (Document) i.next();
       doAddDocument(writer, document, analyzer);
     }
   } catch (IOException ex) {
     throw new LuceneIndexAccessException("Error during adding a document.", ex);
   } finally {
     IndexWriterFactoryUtils.releaseIndexWriter(indexFactory, writer);
   }
 }