Search in sources :

Example 6 with SearchResult

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;
}
Also used : ArrayList(java.util.ArrayList) EntityDoc(com.tyndalehouse.step.core.data.EntityDoc) SearchResult(com.tyndalehouse.step.core.models.search.SearchResult) SubjectHeadingSearchEntry(com.tyndalehouse.step.core.models.search.SubjectHeadingSearchEntry) SearchEntry(com.tyndalehouse.step.core.models.search.SearchEntry) ExpandableSubjectHeadingEntry(com.tyndalehouse.step.core.models.search.ExpandableSubjectHeadingEntry)

Example 7 with SearchResult

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;
}
Also used : EntityDoc(com.tyndalehouse.step.core.data.EntityDoc) ArrayList(java.util.ArrayList) SearchResult(com.tyndalehouse.step.core.models.search.SearchResult) SubjectHeadingSearchEntry(com.tyndalehouse.step.core.models.search.SubjectHeadingSearchEntry) SearchEntry(com.tyndalehouse.step.core.models.search.SearchEntry) ExpandableSubjectHeadingEntry(com.tyndalehouse.step.core.models.search.ExpandableSubjectHeadingEntry)

Example 8 with SearchResult

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);
}
Also used : SearchQuery(com.tyndalehouse.step.core.service.impl.SearchQuery) IndividualSearch(com.tyndalehouse.step.core.service.impl.IndividualSearch) SearchResult(com.tyndalehouse.step.core.models.search.SearchResult)

Example 9 with SearchResult

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;
}
Also used : IndividualSearch(com.tyndalehouse.step.core.service.impl.IndividualSearch) SearchResult(com.tyndalehouse.step.core.models.search.SearchResult) Passage(org.crosswire.jsword.passage.Passage) RangedPassage(org.crosswire.jsword.passage.RangedPassage) VerseKey(org.crosswire.jsword.passage.VerseKey) VerseKey(org.crosswire.jsword.passage.VerseKey) Key(org.crosswire.jsword.passage.Key)

Example 10 with SearchResult

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;
}
Also used : SearchResult(com.tyndalehouse.step.core.models.search.SearchResult)

Aggregations

SearchResult (com.tyndalehouse.step.core.models.search.SearchResult)16 SearchEntry (com.tyndalehouse.step.core.models.search.SearchEntry)5 SubjectHeadingSearchEntry (com.tyndalehouse.step.core.models.search.SubjectHeadingSearchEntry)4 EntityDoc (com.tyndalehouse.step.core.data.EntityDoc)3 ExpandableSubjectHeadingEntry (com.tyndalehouse.step.core.models.search.ExpandableSubjectHeadingEntry)3 IndividualSearch (com.tyndalehouse.step.core.service.impl.IndividualSearch)3 ArrayList (java.util.ArrayList)3 TimelineEventSearchEntry (com.tyndalehouse.step.core.models.search.TimelineEventSearchEntry)2 VerseSearchEntry (com.tyndalehouse.step.core.models.search.VerseSearchEntry)2 SearchQuery (com.tyndalehouse.step.core.service.impl.SearchQuery)2 LookupOption (com.tyndalehouse.step.core.models.LookupOption)1 OsisWrapper (com.tyndalehouse.step.core.models.OsisWrapper)1 KeyedSearchResultSearchEntry (com.tyndalehouse.step.core.models.search.KeyedSearchResultSearchEntry)1 LexicalSearchEntry (com.tyndalehouse.step.core.models.search.LexicalSearchEntry)1 PassageStat (com.tyndalehouse.step.core.models.stats.PassageStat)1 AbortQueryException (com.tyndalehouse.step.core.service.impl.AbortQueryException)1 Key (org.crosswire.jsword.passage.Key)1 Passage (org.crosswire.jsword.passage.Passage)1 RangedPassage (org.crosswire.jsword.passage.RangedPassage)1 VerseKey (org.crosswire.jsword.passage.VerseKey)1