Package org.springmodules.lucene.index

Examples of org.springmodules.lucene.index.LuceneIndexAccessException


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

  private void checkHitsForUpdate(Hits 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


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

    List updatedDocuments=null;
    try {
      Hits hits=searcher.search(new TermQuery(identifierTerm));
      updatedDocuments=documentsModifier.updateDocuments(hits);
    } catch(IOException ex) {
      throw new LuceneIndexAccessException("Error during updating a document.",ex);
    } finally {
      SearcherFactoryUtils.releaseSearcher(searcher);
      IndexReaderFactoryUtils.releaseIndexReader(indexFactory,reader);
    }
View Full Code Here

  public void addIndexes(Directory[] directories) {
    IndexWriter 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() {
    IndexWriter 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) {
    IndexReader reader=IndexReaderFactoryUtils.getIndexReader(indexFactory);
    try {
      return callback.doWithReader(reader);
    } catch(IOException ex) {
      throw new LuceneIndexAccessException("Error during using the IndexReader.",ex);
    } finally {
      IndexReaderFactoryUtils.releaseIndexReader(indexFactory,reader);
    }
  }
View Full Code Here

  public Object write(WriterCallback callback) {
    IndexWriter writer=IndexWriterFactoryUtils.getIndexWriter(indexFactory);
    try {
      return callback.doWithWriter(writer);
    } catch(IOException ex) {
      throw new LuceneIndexAccessException("Error during using the IndexWriter.",ex);
    } finally {
      IndexWriterFactoryUtils.releaseIndexWriter(indexFactory,writer);
    }
  }
View Full Code Here

      if( optimizeIndex ) {
        writer.optimize();
      }
    } catch(IOException ex) {
      logger.error("Error during indexing the directory : "+dirToParse, ex);
      throw new LuceneIndexAccessException("Error during indexing the directory : "+dirToParse, ex);
    } catch(Exception ex) {
      ex.printStackTrace();
    } finally {
      IndexWriterFactoryUtils.releaseIndexWriter(getIndexFactory(), writer);
    }
View Full Code Here

        writer.optimize();
      }
    } catch(Exception ex) {
      ex.printStackTrace();
      logger.error("Error during indexing the datasource", ex);
      throw new LuceneIndexAccessException("Error during indexing the datasource", ex);
    } catch(Throwable t) {
      t.printStackTrace();
    } finally {
      IndexWriterFactoryUtils.releaseIndexWriter(getIndexFactory(), writer);
    }
View Full Code Here

   */
  public static LuceneIndexReader getIndexReader(IndexFactory indexFactory, boolean transaction) {
    try {
      return doGetIndexReader(indexFactory, transaction);
    } catch (IOException ex) {
      throw new LuceneIndexAccessException("Could not get Lucene reader", ex);
    }
  }
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.