Examples of LuceneIndexReader


Examples of org.springmodules.lucene.index.factory.LuceneIndexReader

      IndexReaderFactoryUtils.releaseIndexReader(indexFactory,reader);
    }
  }

  public boolean hasDeletions() {
    LuceneIndexReader reader = IndexReaderFactoryUtils.getIndexReader(indexFactory);
    try {
      return reader.hasDeletions();
    } finally {
      IndexReaderFactoryUtils.releaseIndexReader(indexFactory,reader);
    }
  }
View Full Code Here

Examples of org.springmodules.lucene.index.factory.LuceneIndexReader

  //-------------------------------------------------------------------------
  // Methods dealing with index informations
  //-------------------------------------------------------------------------

  public int getMaxDoc() {
    LuceneIndexReader reader = IndexReaderFactoryUtils.getIndexReader(indexFactory);
    try {
      return reader.maxDoc();
    } finally {
      IndexReaderFactoryUtils.releaseIndexReader(indexFactory,reader);
    }
  }
View Full Code Here

Examples of org.springmodules.lucene.index.factory.LuceneIndexReader

      IndexReaderFactoryUtils.releaseIndexReader(indexFactory,reader);
    }
  }

  public int getNumDocs() {
    LuceneIndexReader reader = IndexReaderFactoryUtils.getIndexReader(indexFactory);
    try {
      return reader.numDocs();
    } finally {
      IndexReaderFactoryUtils.releaseIndexReader(indexFactory,reader);
    }
  }
View Full Code Here

Examples of org.springmodules.lucene.index.factory.LuceneIndexReader

  public void updateDocument(Term identifierTerm, DocumentModifier documentModifier) {
    updateDocument(identifierTerm, documentModifier, null);
  }

  public void updateDocument(Term identifierTerm, DocumentModifier documentModifier, Analyzer analyzer) {
    LuceneIndexReader reader = IndexReaderFactoryUtils.getIndexReader(indexFactory);
    LuceneSearcher searcher = null;
    Document updatedDocument = null;
    try {
      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);
View Full Code Here

Examples of org.springmodules.lucene.index.factory.LuceneIndexReader

  public void updateDocuments(Term identifierTerm, DocumentsModifier documentsModifier) {
    updateDocuments(identifierTerm, documentsModifier, null);
  }

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

Examples of org.springmodules.lucene.index.factory.LuceneIndexReader

  //-------------------------------------------------------------------------
  // Methods dealing with index reader and writer directly
  //-------------------------------------------------------------------------

  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 {
View Full Code Here

Examples of org.springmodules.lucene.index.factory.LuceneIndexReader

  public void afterPropertiesSet() throws Exception {
    if( getDirectory()!=null ) {
      Searcher searcher = new IndexSearcher(getDirectory());
      this.indexSearcher = new SimpleLuceneSearcher(searcher);
    } else if( getIndexFactory()!=null ) {
      LuceneIndexReader indexReader = IndexReaderFactoryUtils.getIndexReader(getIndexFactory());
      Searcher searcher = indexReader.createNativeSearcher();
      this.indexSearcher = new SimpleLuceneSearcher(searcher);
    } else {
      throw new LuceneSearchException("Either a Directory or an IndexReader must be specified.");
    }
  }
View Full Code Here

Examples of org.springmodules.lucene.index.factory.LuceneIndexReader

  public LuceneSearcher getSearcher() throws IOException {
    if( getDirectory()!=null ) {
      Searcher indexSearcher = new IndexSearcher(getDirectory());
      return new SimpleLuceneSearcher(indexSearcher);
    } else if( getIndexFactory()!=null ) {
      LuceneIndexReader indexReader = IndexReaderFactoryUtils.getIndexReader(getIndexFactory());
      Searcher indexSearcher = indexReader.createNativeSearcher();
      return new SimpleLuceneSearcher(indexSearcher);
    } else {
      throw new LuceneSearchException("Either a Directory or an Indexreader must be specified.");
    }
  }
View Full Code Here

Examples of org.springmodules.lucene.index.factory.LuceneIndexReader

  //-------------------------------------------------------------------------
  // Methods dealing with document deletions
  //-------------------------------------------------------------------------

  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);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.