Package org.springmodules.lucene.index

Examples of org.springmodules.lucene.index.LuceneIndexAccessException


  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);
    }
  }
View Full Code Here


      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);
    }
  }
View Full Code Here

        writer.addDocument(document, getAnalyzer());
      } else {
        writer.addDocument(document);
      }
    } else {
      throw new LuceneIndexAccessException("The document created is null.");
    }
  }
View Full Code Here

  // Methods dealing with document updates
  //-------------------------------------------------------------------------

  private void checkHitsForUpdate(LuceneHits hits) {
    if( hits.length()==0 ) {
      throw new LuceneIndexAccessException("The identifier returns no document.");
    }
    if( hits.length()>1 ) {
      throw new LuceneIndexAccessException("The identifier returns more than one document.");
    }
  }
View Full Code Here

      searcher = reader.createSearcher();
      LuceneHits hits = searcher.search(new TermQuery(identifierTerm));
      checkHitsForUpdate(hits);
      updatedDocument = documentModifier.updateDocument(hits.doc(0));
    } catch(Exception ex) {
      throw new LuceneIndexAccessException("Error during updating a document.", ex);
    } finally {
      SearcherFactoryUtils.closeSearcher(searcher);
      IndexReaderFactoryUtils.releaseIndexReader(indexFactory, reader);
    }
View Full Code Here

    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);
    }
View Full Code Here

  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);
    }
  }
View Full Code Here

  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);
    }
  }
View Full Code Here

  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);
    }
  }
View Full Code Here

  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);
    }
  }
View Full Code Here

TOP

Related Classes of org.springmodules.lucene.index.LuceneIndexAccessException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.