Search in sources :

Example 1 with VerseSearchEntry

use of com.tyndalehouse.step.core.models.search.VerseSearchEntry in project step by STEPBible.

the class JSwordSearchServiceImpl method getPassagesForResults.

/**
 * Looks up all passages represented by the key
 *
 * @param result the results that we will be returning
 * @param versions   the bibles under examination
 * @param results the list of results
 * @param context amount of context to add
 * @param options to use to lookup the right parameterization of the text
 * @return the list of entries found
 */
private void getPassagesForResults(SearchResult result, String[] versions, final Key results, final int context, final List<LookupOption> options, String interlinearMode) {
    final List<SearchEntry> resultPassages = new ArrayList<SearchEntry>();
    final Iterator<Key> iterator = ((Passage) results).iterator();
    boolean interlinearModeCaptured = false;
    int count = 0;
    while (iterator.hasNext()) {
        final Key verse = iterator.next();
        final Key lookupKey;
        if (verse instanceof Verse) {
            // then we need to make it into a verse range
            final Verse verseAsVerse = (Verse) verse;
            final VerseRange vr = new VerseRange(verseAsVerse.getVersification(), verseAsVerse);
            vr.blur(context, RestrictionType.NONE);
            lookupKey = vr;
        } else {
            // assume blur is supported
            verse.blur(context, RestrictionType.NONE);
            lookupKey = verse;
        }
        if (count == 1) {
            options.add(LookupOption.HIDE_COMPARE_HEADERS);
        }
        // TODO this is not very efficient so requires refactoring
        final OsisWrapper peakOsisText = this.jsword.peakOsisText(versions, lookupKey, options, interlinearMode);
        resultPassages.add(new VerseSearchEntry(peakOsisText.getReference(), peakOsisText.getValue(), peakOsisText.getOsisId()));
        if (!interlinearModeCaptured) {
            result.setInterlinearMode(peakOsisText.getInterlinearMode());
            interlinearModeCaptured = true;
        }
        count++;
    }
    result.setResults(resultPassages);
}
Also used : VerseSearchEntry(com.tyndalehouse.step.core.models.search.VerseSearchEntry) VerseSearchEntry(com.tyndalehouse.step.core.models.search.VerseSearchEntry) SearchEntry(com.tyndalehouse.step.core.models.search.SearchEntry) OsisWrapper(com.tyndalehouse.step.core.models.OsisWrapper)

Example 2 with VerseSearchEntry

use of com.tyndalehouse.step.core.models.search.VerseSearchEntry in project step by STEPBible.

the class SearchServiceImpl method buildTimelineSearchResults.

/**
 * Construct the relevant entity structure to represent timeline search results
 *
 * @param sq     the search query
 * @param events the list of events retrieved
 * @return the search results
 */
private SearchResult buildTimelineSearchResults(final SearchQuery sq, final EntityDoc[] events) {
    final List<SearchEntry> results = new ArrayList<SearchEntry>();
    final SearchResult r = new SearchResult();
    r.setResults(results);
    for (final EntityDoc e : events) {
        final String refs = e.get("storedReferences");
        final String[] references = StringUtils.split(refs);
        final List<VerseSearchEntry> verses = new ArrayList<VerseSearchEntry>();
        // TODO FIXME: REFACTOR to only make 1 jsword call?
        for (final String ref : references) {
            // TODO: REFACTOR only supports one version lookup
            final VerseSearchEntry verseEntry = new VerseSearchEntry();
            verses.add(verseEntry);
        }
        final TimelineEventSearchEntry entry = new TimelineEventSearchEntry();
        entry.setId(e.get("id"));
        entry.setDescription(e.get("name"));
        entry.setVerses(verses);
        results.add(entry);
    }
    return r;
}
Also used : TimelineEventSearchEntry(com.tyndalehouse.step.core.models.search.TimelineEventSearchEntry) ArrayList(java.util.ArrayList) EntityDoc(com.tyndalehouse.step.core.data.EntityDoc) VerseSearchEntry(com.tyndalehouse.step.core.models.search.VerseSearchEntry) SearchResult(com.tyndalehouse.step.core.models.search.SearchResult) KeyedSearchResultSearchEntry(com.tyndalehouse.step.core.models.search.KeyedSearchResultSearchEntry) TimelineEventSearchEntry(com.tyndalehouse.step.core.models.search.TimelineEventSearchEntry) VerseSearchEntry(com.tyndalehouse.step.core.models.search.VerseSearchEntry) SearchEntry(com.tyndalehouse.step.core.models.search.SearchEntry) LexicalSearchEntry(com.tyndalehouse.step.core.models.search.LexicalSearchEntry)

Example 3 with VerseSearchEntry

use of com.tyndalehouse.step.core.models.search.VerseSearchEntry in project step by STEPBible.

the class JSwordSearchServiceImplTest method testMorphology.

/**
 * Random tests
 */
@Test
public void testMorphology() {
    final List<SearchEntry> results = this.search.search(new SearchQuery("+[Mat-Rev] +morph:G2570*A-NSM*", new String[] { "KJV" }, "true", 0, 1, 1000000, null), "ESV_th").getResults();
    for (SearchEntry result : results) {
        LOGGER.info(((VerseSearchEntry) result).getKey());
    }
    assertFalse(results.isEmpty());
}
Also used : SearchQuery(com.tyndalehouse.step.core.service.impl.SearchQuery) VerseSearchEntry(com.tyndalehouse.step.core.models.search.VerseSearchEntry) SearchEntry(com.tyndalehouse.step.core.models.search.SearchEntry) Test(org.junit.Test)

Example 4 with VerseSearchEntry

use of com.tyndalehouse.step.core.models.search.VerseSearchEntry in project step by STEPBible.

the class JSwordSearchServiceImplTest method testGood.

/**
 * Random tests
 */
@Test
public void testGood() {
    final List<SearchEntry> results = this.search.search(new SearchQuery("+[Mat-Rev] good~", new String[] { "ESV_th" }, "true", 0, 1, 1000000, null), "ESV_th").getResults();
    for (SearchEntry result : results) {
        LOGGER.trace(((VerseSearchEntry) result).getKey());
    }
    assertFalse(results.isEmpty());
}
Also used : SearchQuery(com.tyndalehouse.step.core.service.impl.SearchQuery) VerseSearchEntry(com.tyndalehouse.step.core.models.search.VerseSearchEntry) SearchEntry(com.tyndalehouse.step.core.models.search.SearchEntry) Test(org.junit.Test)

Example 5 with VerseSearchEntry

use of com.tyndalehouse.step.core.models.search.VerseSearchEntry in project step by STEPBible.

the class SearchServiceImplTest method testSubjectSearch.

/**
 * test exact strong match
 */
@Test
public void testSubjectSearch() {
    final SearchResult searchSubject = this.searchServiceUnderTest.search(new SearchQuery("sh=elijah", new String[] { "ESV_th" }, "false", 0, 1, 1, null));
    final List<SearchEntry> entries = ((SubjectHeadingSearchEntry) searchSubject.getResults().get(0)).getHeadingsSearch().getResults();
    for (final SearchEntry e : entries) {
        LOGGER.debug(((VerseSearchEntry) e).getPreview());
    }
    assertTrue(searchSubject.getResults().size() > 0);
}
Also used : SearchQuery(com.tyndalehouse.step.core.service.impl.SearchQuery) SearchResult(com.tyndalehouse.step.core.models.search.SearchResult) SubjectHeadingSearchEntry(com.tyndalehouse.step.core.models.search.SubjectHeadingSearchEntry) VerseSearchEntry(com.tyndalehouse.step.core.models.search.VerseSearchEntry) TimelineEventSearchEntry(com.tyndalehouse.step.core.models.search.TimelineEventSearchEntry) SearchEntry(com.tyndalehouse.step.core.models.search.SearchEntry) Test(org.junit.Test)

Aggregations

SearchEntry (com.tyndalehouse.step.core.models.search.SearchEntry)5 VerseSearchEntry (com.tyndalehouse.step.core.models.search.VerseSearchEntry)5 SearchQuery (com.tyndalehouse.step.core.service.impl.SearchQuery)3 Test (org.junit.Test)3 SearchResult (com.tyndalehouse.step.core.models.search.SearchResult)2 TimelineEventSearchEntry (com.tyndalehouse.step.core.models.search.TimelineEventSearchEntry)2 EntityDoc (com.tyndalehouse.step.core.data.EntityDoc)1 OsisWrapper (com.tyndalehouse.step.core.models.OsisWrapper)1 KeyedSearchResultSearchEntry (com.tyndalehouse.step.core.models.search.KeyedSearchResultSearchEntry)1 LexicalSearchEntry (com.tyndalehouse.step.core.models.search.LexicalSearchEntry)1 SubjectHeadingSearchEntry (com.tyndalehouse.step.core.models.search.SubjectHeadingSearchEntry)1 ArrayList (java.util.ArrayList)1