use of com.tyndalehouse.step.core.models.search.SearchResult in project step by STEPBible.
the class AnalysisServiceImpl method getSubjectStats.
/**
* Subject stats.
*
* @param version the version
* @param reference the reference
* @param scopeType
* @return the passage stat
*/
private PassageStat getSubjectStats(final String version, final String reference, final ScopeType scopeType) {
final SearchResult subjectResults = this.subjects.searchByReference(getReferenceSyntax(reference, version, scopeType));
final PassageStat stat = new PassageStat();
// we duplicate the set here because we'd like to keep the casing...
final List<SearchEntry> results = subjectResults.getResults();
for (final SearchEntry entry : results) {
if (entry instanceof ExpandableSubjectHeadingEntry) {
final ExpandableSubjectHeadingEntry subjectEntry = (ExpandableSubjectHeadingEntry) entry;
// we will first do the subheading because ideally we want that 'case' to be the master case,
// i.e. David rather than DAVID
final String subjectHeading = subjectEntry.getHeading();
if (subjectHeading != null && !stopSubjects.contains(subjectHeading.toUpperCase())) {
stat.addWordTryCases(CLEAN_UP_DIGITS.matcher(subjectHeading).replaceAll(""));
}
final String root = subjectEntry.getRoot();
if (root != null && !stopSubjects.contains(root.toUpperCase())) {
stat.addWordTryCases(CLEAN_UP_DIGITS.matcher(root).replaceAll(root));
}
}
}
return stat;
}
use of com.tyndalehouse.step.core.models.search.SearchResult 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;
}
use of com.tyndalehouse.step.core.models.search.SearchResult in project step by STEPBible.
the class SearchServiceImpl method runStrongTextSearch.
/**
* Runs the search, and adds the strongs to the search results
*
* @param sq the search criteria
* @param strongs the list of strongs that were searched for
* @return the search results
*/
private SearchResult runStrongTextSearch(final SearchQuery sq, final Set<String> strongs, final String options) {
Key key = runStrongTextSearchKeys(sq, strongs);
final SearchResult textResults = buildCombinedVerseBasedResults(sq, key, options);
textResults.setStrongHighlights(new ArrayList<>(strongs));
return textResults;
}
use of com.tyndalehouse.step.core.models.search.SearchResult in project step by STEPBible.
the class SearchServiceImpl method doSearch.
/**
* Carries out the required search
*
* @param sq the sq
* @return the search result
*/
private SearchResult doSearch(final SearchQuery sq, final String options) {
final long start = System.currentTimeMillis();
SearchResult result;
// if we've only got one search, we want to retrieve the keys, the page, etc. all in one go
try {
if (sq.isIndividualSearch()) {
result = executeOneSearch(sq, options);
} else {
result = executeJoiningSearches(sq);
}
} catch (final AbortQueryException ex) {
result = new SearchResult();
}
// we split the query into separate searches
// we run the search against the selected versions
// we retrieve the keys
// join the keys
// return the results
result.setSearchType(getBestSearchType(sq));
result.setPageSize(sq.getPageSize());
result.setPageNumber(sq.getPageNumber());
result.setTimeTookTotal(System.currentTimeMillis() - start);
result.setQuery(sq.getOriginalQuery());
setBestRestriction(sq, result);
final String[] allVersions = sq.getCurrentSearch().getVersions();
result.setMasterVersion(this.versionResolver.getShortName(allVersions[0]));
result.setExtraVersions(StringUtils.join(allVersions, 1));
specialSort(sq, result);
enrichWithLanguages(sq, result);
return result;
}
use of com.tyndalehouse.step.core.models.search.SearchResult in project step by STEPBible.
the class SubjectSearchServiceImpl method getResultsAsHeadings.
private SearchResult getResultsAsHeadings(SearchQuery sq, String[] searchableVersions, Key allTopics) {
final SearchResult headingsSearch = this.jswordSearch.getResultsFromTrimmedKeys(sq, searchableVersions, allTopics.getCardinality(), allTopics, HEADINGS_ONLY);
// build the results and then return
final SubjectHeadingSearchEntry headings = new SubjectHeadingSearchEntry();
headings.setHeadingsSearch(headingsSearch);
// return the results
final SearchResult sr = new SearchResult();
sr.addEntry(headings);
sr.setTotal(headingsSearch.getTotal());
sr.setTimeTookToRetrieveScripture(headingsSearch.getTimeTookToRetrieveScripture());
return sr;
}
Aggregations