use of com.tyndalehouse.step.core.service.impl.IndividualSearch in project step by STEPBible.
the class SearchServiceImpl method runStrongTextSearchKeys.
private Key runStrongTextSearchKeys(SearchQuery sq, Set<String> strongs) {
// searches for strongs have got slightly more complicated now that we are doing augmented strongs as well...
// so for example, we have the query strong:h00001 strong:h00002 strong:h00003 strong:h00004a strong:h00005a
// we can run a simple strong search for normal strong numbers
// unfortunately, we to need run an extra search for each of the augmented strong numbers
// split the search into the standard search and the other searches
final List<String> augmentedStrongs = new ArrayList<>(2);
final IndividualSearch currentSearch = sq.getCurrentSearch();
String currentQuery = currentSearch.getQuery();
final Matcher matchAugmentedStrongs = AUGMENTED_STRONG.matcher(currentQuery);
final String simpleStrongSearch = matchAugmentedStrongs.replaceAll("");
matchAugmentedStrongs.reset();
while (matchAugmentedStrongs.find()) {
final String as = matchAugmentedStrongs.group(1);
augmentedStrongs.add(as);
strongs.add(this.strongAugmentationService.reduce(as).toUpperCase());
}
// run the normal search
Key key = null;
if (simpleStrongSearch.contains("strong")) {
currentSearch.setQuery(simpleStrongSearch);
key = this.jswordSearch.searchKeys(sq);
}
// work out the original query without the normal strong numbers
String blankQuery = ALL_STRONGS.matcher(currentQuery).replaceAll("");
for (String as : augmentedStrongs) {
currentSearch.setQuery(blankQuery + " strong:" + as.substring(0, as.length() - 1));
Key potentialAugmentedResults = this.jswordSearch.searchKeys(sq);
// filter results by augmented strong data set
Key masterAugmentedFilter = this.strongAugmentationService.getVersesForAugmentedStrong(as);
potentialAugmentedResults = intersect(potentialAugmentedResults, masterAugmentedFilter);
// add results to current set
if (key == null) {
key = potentialAugmentedResults;
} else {
key.addAll(potentialAugmentedResults);
}
}
currentSearch.setQuery(currentQuery);
return key;
}
use of com.tyndalehouse.step.core.service.impl.IndividualSearch in project step by STEPBible.
the class SearchServiceImpl method enrichWithLanguages.
/**
* Puts the languages of each module into the result returned to the UI.
*
* @param sq the search query
* @param result the result
*/
private void enrichWithLanguages(final SearchQuery sq, final SearchResult result) {
IndividualSearch lastSearch = sq.getCurrentSearch();
result.setLanguageCode(jswordMetadata.getLanguages(lastSearch.getVersions()));
}
Aggregations