Search in sources :

Example 1 with LuceneSearchException

use of com.tyndalehouse.step.core.exceptions.LuceneSearchException in project step by STEPBible.

the class JSwordSearchServiceImpl method doSearch.

private void doSearch(final DefaultSearchModifier modifier, final Map<String, Key> resultsPerVersion, final IndividualSearch currentSearch, final Book bible) {
    String version = bible.getInitials();
    if (bible.getIndexStatus().equals(IndexStatus.DONE)) {
        final Key luceneSearchResults;
        try {
            String query = currentSearch.getQuery();
            // small optimization and cater for versions that don't support Gen-Rev as a range:
            query = GEN_REV_RANGE.matcher(query).replaceAll("");
            luceneSearchResults = bible.find(new DefaultSearchRequest(query, modifier));
        } catch (final BookException e) {
            throw new LuceneSearchException("Unable to search for " + currentSearch.getQuery() + " with Bible " + version, e);
        }
        resultsPerVersion.put(version, luceneSearchResults);
    } else {
        LOGGER.error("Module [{}] is not indexed.", version);
        resultsPerVersion.put(version, PassageKeyFactory.instance().createEmptyKeyList(av11nService.getVersificationForVersion(bible)));
    }
}
Also used : DefaultSearchRequest(org.crosswire.jsword.index.search.DefaultSearchRequest) BookException(org.crosswire.jsword.book.BookException) LuceneSearchException(com.tyndalehouse.step.core.exceptions.LuceneSearchException)

Aggregations

LuceneSearchException (com.tyndalehouse.step.core.exceptions.LuceneSearchException)1 BookException (org.crosswire.jsword.book.BookException)1 DefaultSearchRequest (org.crosswire.jsword.index.search.DefaultSearchRequest)1