use of com.tyndalehouse.step.core.service.impl.IndividualSearch in project step by STEPBible.
the class SearchServiceImpl method getStrongsFromCurrentSearch.
/**
* splits up the query syntax and returns a list of all strong numbers required
*
* @param sq the search query
* @return the list of strongs
*/
private Set<String> getStrongsFromCurrentSearch(final SearchQuery sq) {
final IndividualSearch currentSearch = sq.getCurrentSearch();
final String searchStrong = currentSearch.getQuery();
LOGGER.debug("Searching for strongs [{}]", searchStrong);
return splitToStrongs(searchStrong, sq.getCurrentSearch().getType());
}
use of com.tyndalehouse.step.core.service.impl.IndividualSearch in project step by STEPBible.
the class SubjectSearchServiceImpl method search.
@Override
public SearchResult search(final SearchQuery sq) {
final IndividualSearch currentSearch = sq.getCurrentSearch();
LOGGER.debug("Executing subject search of type [{}]", currentSearch.getType());
SearchQuery currentQuery = sq;
switch(currentSearch.getType()) {
case SUBJECT_SIMPLE:
final SearchResult simpleSearchResults = searchSimple(currentQuery);
return simpleSearchResults;
case SUBJECT_EXTENDED:
final SearchResult searchResult = searchExtended(currentQuery);
searchResult.setQuery(currentSearch.getQuery());
return searchResult;
case SUBJECT_FULL:
return searchFull(currentQuery);
case SUBJECT_RELATED:
return relatedSubjects(currentQuery);
default:
break;
}
return searchSimple(currentQuery);
}
use of com.tyndalehouse.step.core.service.impl.IndividualSearch in project step by STEPBible.
the class SubjectSearchServiceImpl method searchSimple.
/**
* runs a simple subject search
*
* @param sq the search query
* @return the results
*/
private SearchResult searchSimple(final SearchQuery sq) {
// ensure we're using the latest range
final IndividualSearch currentSearch = sq.getCurrentSearch();
currentSearch.setQuery(currentSearch.getQuery(), true);
final String[] originalVersions = currentSearch.getVersions();
final String[] searchableVersions = prepareSearchForHeadings(sq);
final Key allTopics = this.jswordSearch.searchKeys(sq);
// we will need to restrict the results by the scope of the versions, in the ESV v11n
final Passage maxScope = getScopeForVersions(originalVersions);
allTopics.retainAll(VersificationsMapper.instance().map(maxScope, ((VerseKey) allTopics).getVersification()));
SearchResult resultsAsHeadings = getResultsAsHeadings(sq, searchableVersions, allTopics);
cleanUpSearchFromHeadingsSearch(sq, originalVersions);
return resultsAsHeadings;
}
use of com.tyndalehouse.step.core.service.impl.IndividualSearch in project step by STEPBible.
the class SearchServiceImpl method runTextSearch.
/**
* Runs a text search, collapsing the restrictions if need be
*
* @param sq the search query contained
* @return the search to be run
*/
private SearchResult runTextSearch(final SearchQuery sq) {
final IndividualSearch currentSearch = sq.getCurrentSearch();
final String secondaryRange = currentSearch.getSecondaryRange();
if (StringUtils.isBlank(secondaryRange)) {
return runJSwordTextSearch(sq);
}
final String[] versions = currentSearch.getVersions();
final String masterVersion = versions[0];
final Book bookFromVersion = this.versificationService.getBookFromVersion(masterVersion);
Key k;
try {
k = bookFromVersion.getKey(secondaryRange);
} catch (NoSuchKeyException e) {
throw new TranslatedException(e, "invalid_reference_in_book", secondaryRange, bookFromVersion.getInitials());
}
k = intersect(k, this.jswordSearch.searchKeys(sq));
return this.getSearchResultFromKey(sq, k);
}
use of com.tyndalehouse.step.core.service.impl.IndividualSearch 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;
}
Aggregations