Search in sources :

Example 1 with IndexManager

use of org.crosswire.jsword.index.IndexManager in project step by STEPBible.

the class JSwordSearchServiceImpl method getIndexSearcher.

/**
 * Retrieves the index from JSword
 * @param bookName the book name
 * @return the index searcher responsible for carrying out operations on JSword data.
 */
public IndexSearcher getIndexSearcher(String bookName) {
    final IndexManager indexManager = IndexManagerFactory.getIndexManager();
    Index index;
    try {
        index = indexManager.getIndex(this.av11nService.getBookFromVersion(bookName));
    } catch (BookException e) {
        throw new StepInternalException(e.getMessage(), e);
    }
    if (!(index instanceof LuceneIndex)) {
        LOGGER.warn("Unsupported Lucene Index type [{}]", index.getClass());
        throw new StepInternalException("Unable to obtain index");
    }
    @SuppressWarnings("resource") final LuceneIndex li = (LuceneIndex) index;
    return (IndexSearcher) li.getSearcher();
}
Also used : IndexManager(org.crosswire.jsword.index.IndexManager) IndexSearcher(org.apache.lucene.search.IndexSearcher) LuceneIndex(org.crosswire.jsword.index.lucene.LuceneIndex) StepInternalException(com.tyndalehouse.step.core.exceptions.StepInternalException) Index(org.crosswire.jsword.index.Index) LuceneIndex(org.crosswire.jsword.index.lucene.LuceneIndex) BookException(org.crosswire.jsword.book.BookException)

Example 2 with IndexManager

use of org.crosswire.jsword.index.IndexManager in project step by STEPBible.

the class JSwordModuleServiceImpl method index.

@Override
public void index(final String initials) {
    final IndexManager indexManager = IndexManagerFactory.getIndexManager();
    final Book book = this.versificationService.getBookFromVersion(initials);
    if (!indexManager.isIndexed(book)) {
        indexManager.scheduleIndexCreation(book);
    }
}
Also used : IndexManager(org.crosswire.jsword.index.IndexManager) Book(org.crosswire.jsword.book.Book)

Aggregations

IndexManager (org.crosswire.jsword.index.IndexManager)2 StepInternalException (com.tyndalehouse.step.core.exceptions.StepInternalException)1 IndexSearcher (org.apache.lucene.search.IndexSearcher)1 Book (org.crosswire.jsword.book.Book)1 BookException (org.crosswire.jsword.book.BookException)1 Index (org.crosswire.jsword.index.Index)1 LuceneIndex (org.crosswire.jsword.index.lucene.LuceneIndex)1