Search in sources :

Example 1 with InternalCompassSession

use of org.compass.core.spi.InternalCompassSession in project Gemma by PavlidisLab.

the class SearchServiceImpl method performSearch.

/**
 * Runs inside Compass transaction
 */
private Collection<SearchResult> performSearch(SearchSettings settings, CompassSession session) {
    StopWatch watch = this.startTiming();
    String enhancedQuery = settings.getQuery().trim();
    // noinspection ConstantConditions // Not obvious to me why that would have to be false.
    if (StringUtils.isBlank(enhancedQuery) || enhancedQuery.length() < SearchServiceImpl.MINIMUM_STRING_LENGTH_FOR_FREE_TEXT_SEARCH || enhancedQuery.equals("*"))
        return new ArrayList<>();
    CompassQuery compassQuery = session.queryBuilder().queryString(enhancedQuery).toQuery();
    SearchServiceImpl.log.debug("Parsed query: " + compassQuery);
    CompassHits hits = compassQuery.hits();
    // highlighting.
    if (((SearchSettingsImpl) settings).getDoHighlighting()) {
        if (session instanceof InternalCompassSession) {
            // always ...
            CompassMapping mapping = ((InternalCompassSession) session).getMapping();
            ResourceMapping[] rootMappings = mapping.getRootMappings();
            // should only be one rootMapping.
            this.process(rootMappings, hits);
        }
    }
    watch.stop();
    if (watch.getTime() > 100) {
        SearchServiceImpl.log.info("Getting " + hits.getLength() + " lucene hits for " + enhancedQuery + " took " + watch.getTime() + " ms");
    }
    if (watch.getTime() > 5000) {
        SearchServiceImpl.log.info("*****Extremely long Lucene Index Search!  " + hits.getLength() + " lucene hits for " + enhancedQuery + " took " + watch.getTime() + " ms");
    }
    return this.getSearchResults(hits);
}
Also used : SearchSettingsImpl(ubic.gemma.model.common.search.SearchSettingsImpl) InternalCompassSession(org.compass.core.spi.InternalCompassSession) CompassMapping(org.compass.core.mapping.CompassMapping) ResourceMapping(org.compass.core.mapping.ResourceMapping) StopWatch(org.apache.commons.lang3.time.StopWatch)

Aggregations

StopWatch (org.apache.commons.lang3.time.StopWatch)1 CompassMapping (org.compass.core.mapping.CompassMapping)1 ResourceMapping (org.compass.core.mapping.ResourceMapping)1 InternalCompassSession (org.compass.core.spi.InternalCompassSession)1 SearchSettingsImpl (ubic.gemma.model.common.search.SearchSettingsImpl)1