Search in sources :

Example 11 with SearchResult

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

the class SearchServiceImpl method buildCombinedVerseBasedResults.

/**
 * Builds the combined results
 *
 * @param sq      the search query object
 * @param results the set of keys that have been retrieved by each search
 * @return the set of results
 */
private SearchResult buildCombinedVerseBasedResults(final SearchQuery sq, final Key results, final String options) {
    // combine the results into 1 giant keyed map
    final IndividualSearch currentSearch = sq.getCurrentSearch();
    Key adaptedResults = results;
    if (adaptedResults == null) {
        adaptedResults = PassageKeyFactory.instance().createEmptyKeyList(this.versificationService.getVersificationForVersion(JSwordPassageService.BEST_VERSIFICATION));
    }
    int total = adaptedResults.getCardinality();
    final Key pagedKeys = this.jswordSearch.rankAndTrimResults(sq, adaptedResults);
    // retrieve scripture content and set up basics
    final SearchResult resultsForKeys = this.jswordSearch.getResultsFromTrimmedKeys(sq, currentSearch.getVersions(), total, pagedKeys, options);
    resultsForKeys.setTotal(this.jswordSearch.getTotal(adaptedResults));
    resultsForKeys.setQuery(sq.getOriginalQuery());
    return resultsForKeys;
}
Also used : IndividualSearch(com.tyndalehouse.step.core.service.impl.IndividualSearch) SearchResult(com.tyndalehouse.step.core.models.search.SearchResult)

Example 12 with SearchResult

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

the class SearchServiceImpl method runRelatedStrongSearch.

/**
 * Looks up all related strongs then runs the search
 *
 * @param sq the search query
 * @return the results
 */
private SearchResult runRelatedStrongSearch(final SearchQuery sq, SuggestionType suggestionType, final String options) {
    final Set<String> strongs = adaptQueryForRelatedStrongSearch(sq);
    // and then run the search
    final SearchResult result = runStrongTextSearch(sq, strongs, options);
    setDefinitionForResults(result, sq.getDefinitions(), suggestionType);
    return result;
}
Also used : SearchResult(com.tyndalehouse.step.core.models.search.SearchResult)

Example 13 with SearchResult

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

the class SearchServiceImpl method runMeaningSearch.

/**
 * Obtains all glosses with a particular meaning
 *
 * @param sq the search criteria
 * @return the result from the corresponding text search
 */
private SearchResult runMeaningSearch(final SearchQuery sq) {
    final Set<String> strongs = adaptQueryForMeaningSearch(sq);
    // Options from user was not passed to this method
    final SearchResult result = runStrongTextSearch(sq, strongs, "");
    setDefinitionForResults(result, sq.getDefinitions(), SuggestionType.MEANING);
    // we can now use the filter and save ourselves some effort
    return result;
}
Also used : SearchResult(com.tyndalehouse.step.core.models.search.SearchResult)

Example 14 with SearchResult

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

the class JSwordSearchServiceImpl method getResultsFromTrimmedKeys.

public SearchResult getResultsFromTrimmedKeys(final SearchQuery sq, final String[] versions, final int total, final Key newResults, final LookupOption... options) {
    final long startRefRetrieval = System.currentTimeMillis();
    // if context > 0, then we need to add verse numbers:
    final List<LookupOption> lookupOptions = new ArrayList<LookupOption>();
    Collections.addAll(lookupOptions, options);
    lookupOptions.add(LookupOption.CHAPTER_BOOK_VERSE_NUMBER);
    lookupOptions.add(LookupOption.HEBREW_VOWELS);
    lookupOptions.add(LookupOption.GREEK_ACCENTS);
    // lookupOptions.add(LookupOption.HEBREW_ACCENTS); Removed because we want to show Hebrew accents only if the user has selected this option.
    final SearchResult r = new SearchResult();
    getPassagesForResults(r, versions, newResults, sq.getContext(), lookupOptions, sq.getInterlinearMode());
    return getSearchResult(r, total, System.currentTimeMillis() - startRefRetrieval);
}
Also used : LookupOption(com.tyndalehouse.step.core.models.LookupOption) SearchResult(com.tyndalehouse.step.core.models.search.SearchResult)

Example 15 with SearchResult

use of com.tyndalehouse.step.core.models.search.SearchResult 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

SearchResult (com.tyndalehouse.step.core.models.search.SearchResult)16 SearchEntry (com.tyndalehouse.step.core.models.search.SearchEntry)5 SubjectHeadingSearchEntry (com.tyndalehouse.step.core.models.search.SubjectHeadingSearchEntry)4 EntityDoc (com.tyndalehouse.step.core.data.EntityDoc)3 ExpandableSubjectHeadingEntry (com.tyndalehouse.step.core.models.search.ExpandableSubjectHeadingEntry)3 IndividualSearch (com.tyndalehouse.step.core.service.impl.IndividualSearch)3 ArrayList (java.util.ArrayList)3 TimelineEventSearchEntry (com.tyndalehouse.step.core.models.search.TimelineEventSearchEntry)2 VerseSearchEntry (com.tyndalehouse.step.core.models.search.VerseSearchEntry)2 SearchQuery (com.tyndalehouse.step.core.service.impl.SearchQuery)2 LookupOption (com.tyndalehouse.step.core.models.LookupOption)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 PassageStat (com.tyndalehouse.step.core.models.stats.PassageStat)1 AbortQueryException (com.tyndalehouse.step.core.service.impl.AbortQueryException)1 Key (org.crosswire.jsword.passage.Key)1 Passage (org.crosswire.jsword.passage.Passage)1 RangedPassage (org.crosswire.jsword.passage.RangedPassage)1 VerseKey (org.crosswire.jsword.passage.VerseKey)1