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);
}
Aggregations