use of com.tyndalehouse.step.core.models.search.VerseSearchEntry in project step by STEPBible.
the class JSwordSearchServiceImpl method getPassagesForResults.
/**
* Looks up all passages represented by the key
*
* @param result the results that we will be returning
* @param versions the bibles under examination
* @param results the list of results
* @param context amount of context to add
* @param options to use to lookup the right parameterization of the text
* @return the list of entries found
*/
private void getPassagesForResults(SearchResult result, String[] versions, final Key results, final int context, final List<LookupOption> options, String interlinearMode) {
final List<SearchEntry> resultPassages = new ArrayList<SearchEntry>();
final Iterator<Key> iterator = ((Passage) results).iterator();
boolean interlinearModeCaptured = false;
int count = 0;
while (iterator.hasNext()) {
final Key verse = iterator.next();
final Key lookupKey;
if (verse instanceof Verse) {
// then we need to make it into a verse range
final Verse verseAsVerse = (Verse) verse;
final VerseRange vr = new VerseRange(verseAsVerse.getVersification(), verseAsVerse);
vr.blur(context, RestrictionType.NONE);
lookupKey = vr;
} else {
// assume blur is supported
verse.blur(context, RestrictionType.NONE);
lookupKey = verse;
}
if (count == 1) {
options.add(LookupOption.HIDE_COMPARE_HEADERS);
}
// TODO this is not very efficient so requires refactoring
final OsisWrapper peakOsisText = this.jsword.peakOsisText(versions, lookupKey, options, interlinearMode);
resultPassages.add(new VerseSearchEntry(peakOsisText.getReference(), peakOsisText.getValue(), peakOsisText.getOsisId()));
if (!interlinearModeCaptured) {
result.setInterlinearMode(peakOsisText.getInterlinearMode());
interlinearModeCaptured = true;
}
count++;
}
result.setResults(resultPassages);
}
use of com.tyndalehouse.step.core.models.search.VerseSearchEntry 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.VerseSearchEntry in project step by STEPBible.
the class JSwordSearchServiceImplTest method testMorphology.
/**
* Random tests
*/
@Test
public void testMorphology() {
final List<SearchEntry> results = this.search.search(new SearchQuery("+[Mat-Rev] +morph:G2570*A-NSM*", new String[] { "KJV" }, "true", 0, 1, 1000000, null), "ESV_th").getResults();
for (SearchEntry result : results) {
LOGGER.info(((VerseSearchEntry) result).getKey());
}
assertFalse(results.isEmpty());
}
use of com.tyndalehouse.step.core.models.search.VerseSearchEntry in project step by STEPBible.
the class JSwordSearchServiceImplTest method testGood.
/**
* Random tests
*/
@Test
public void testGood() {
final List<SearchEntry> results = this.search.search(new SearchQuery("+[Mat-Rev] good~", new String[] { "ESV_th" }, "true", 0, 1, 1000000, null), "ESV_th").getResults();
for (SearchEntry result : results) {
LOGGER.trace(((VerseSearchEntry) result).getKey());
}
assertFalse(results.isEmpty());
}
use of com.tyndalehouse.step.core.models.search.VerseSearchEntry 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