use of org.olat.search.service.searcher.SearchResultsImpl in project openolat by klemens.
the class SearchCallable method call.
@Override
public SearchResults call() throws ParseException {
IndexSearcher searcher = null;
try {
boolean debug = log.isDebug();
if (!searchService.existIndex()) {
log.warn("Index does not exist, can't search for queryString: " + queryString);
throw new ServiceNotAvailableException("Index does not exist");
}
if (debug)
log.debug("queryString=" + queryString);
searcher = searchService.getIndexSearcher();
BooleanQuery query = searchService.createQuery(queryString, condQueries);
if (debug)
log.debug("query=" + query);
if (Thread.interrupted()) {
throw new InterruptedException();
}
long startTime = System.currentTimeMillis();
int n = SearchServiceFactory.getService().getSearchModuleConfig().getMaxHits();
TopDocs docs = searcher.search(query, n);
long queryTime = System.currentTimeMillis() - startTime;
if (debug)
log.debug("hits.length()=" + docs.totalHits);
SearchResultsImpl searchResult = new SearchResultsImpl(searchService.getMainIndexer(), searcher, docs, query, searchService.getAnalyzer(), identity, roles, firstResult, maxResults, doHighlighting, false);
searchResult.setQueryTime(queryTime);
searchResult.setNumberOfIndexDocuments(docs.totalHits);
if (debug)
log.debug("found=" + docs.totalHits);
return searchResult;
} catch (ParseException pex) {
throw pex;
} catch (Exception naex) {
log.error("", naex);
return null;
} finally {
searchService.releaseIndexSearcher(searcher);
DBFactory.getInstance().commitAndCloseSession();
}
}
use of org.olat.search.service.searcher.SearchResultsImpl in project OpenOLAT by OpenOLAT.
the class SearchCallable method call.
@Override
public SearchResults call() throws ParseException {
IndexSearcher searcher = null;
try {
boolean debug = log.isDebug();
if (!searchService.existIndex()) {
log.warn("Index does not exist, can't search for queryString: " + queryString);
throw new ServiceNotAvailableException("Index does not exist");
}
if (debug)
log.debug("queryString=" + queryString);
searcher = searchService.getIndexSearcher();
BooleanQuery query = searchService.createQuery(queryString, condQueries);
if (debug)
log.debug("query=" + query);
if (Thread.interrupted()) {
throw new InterruptedException();
}
long startTime = System.currentTimeMillis();
int n = SearchServiceFactory.getService().getSearchModuleConfig().getMaxHits();
TopDocs docs = searcher.search(query, n);
long queryTime = System.currentTimeMillis() - startTime;
if (debug)
log.debug("hits.length()=" + docs.totalHits);
SearchResultsImpl searchResult = new SearchResultsImpl(searchService.getMainIndexer(), searcher, docs, query, searchService.getAnalyzer(), identity, roles, firstResult, maxResults, doHighlighting, false);
searchResult.setQueryTime(queryTime);
searchResult.setNumberOfIndexDocuments(docs.totalHits);
if (debug)
log.debug("found=" + docs.totalHits);
return searchResult;
} catch (ParseException pex) {
throw pex;
} catch (Exception naex) {
log.error("", naex);
return null;
} finally {
searchService.releaseIndexSearcher(searcher);
DBFactory.getInstance().commitAndCloseSession();
}
}
Aggregations