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;
}
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;
}
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;
}
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);
}
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);
}
Aggregations