use of com.tyndalehouse.step.core.models.search.SearchResult in project step by STEPBible.
the class SubjectSearchServiceImpl method getHeadingsSearchEntries.
/**
* @param start the start time
* @param results the results that have been found
* @return the list of results
*/
private SearchResult getHeadingsSearchEntries(final long start, final EntityDoc[] results) {
final List<SearchEntry> headingMatches = new ArrayList<SearchEntry>(results.length);
for (final EntityDoc d : results) {
headingMatches.add(new ExpandableSubjectHeadingEntry(d.get("root"), d.get("fullHeader"), d.get("alternate")));
}
// sort the results
Collections.sort(headingMatches, new Comparator<SearchEntry>() {
@Override
public int compare(final SearchEntry o1, final SearchEntry o2) {
final ExpandableSubjectHeadingEntry e1 = (ExpandableSubjectHeadingEntry) o1;
final ExpandableSubjectHeadingEntry e2 = (ExpandableSubjectHeadingEntry) o2;
return compareSubjectEntries(e1, e2);
}
});
final SearchResult sr = new SearchResult();
sr.setTimeTookTotal(System.currentTimeMillis() - start);
sr.setTimeTookToRetrieveScripture(0);
sr.setResults(headingMatches);
sr.setTotal(headingMatches.size());
return sr;
}
use of com.tyndalehouse.step.core.models.search.SearchResult in project step by STEPBible.
the class SubjectSearchServiceImpl method searchByReference.
@Override
public SearchResult searchByReference(final String referenceQuerySyntax) {
final SearchResult sr = new SearchResult();
sr.setQuery("sr=" + referenceQuerySyntax);
// referenceQuerySyntax could be a full referenceQuerySyntax, or could be the start of a referenceQuerySyntax here
final EntityDoc[] results = getDocsByExpandedReferences(referenceQuerySyntax);
final List<SearchEntry> resultList = new ArrayList<SearchEntry>(results.length);
for (final EntityDoc d : results) {
final ExpandableSubjectHeadingEntry entry = new ExpandableSubjectHeadingEntry(d.get("root"), d.get("fullHeader"), d.get("alternate"));
resultList.add(entry);
}
sr.setResults(resultList);
sr.setTotal(resultList.size());
return sr;
}
use of com.tyndalehouse.step.core.models.search.SearchResult 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.models.search.SearchResult 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.models.search.SearchResult in project step by STEPBible.
the class SearchServiceImpl method runExactOriginalTextSearch.
/**
* Runs a search using the exact form, i.e. without any lookups, a straight text search on the original text
*
* @param sq the search criteria
* @return the results to be shown
*/
private SearchResult runExactOriginalTextSearch(final SearchQuery sq) {
final Key resultKeys = getKeysFromOriginalText(sq);
final SearchResult searchResult = extractSearchResults(sq, resultKeys);
searchResult.setStrongHighlights(getStrongs(this.specificForms.search("accentedUnicode", sq.getCurrentSearch().getQuery())));
// return results from appropriate versions
return searchResult;
}
Aggregations