use of org.apache.lucene.search.TimeLimitingCollector in project lucene-solr by apache.
the class Grouping method searchWithTimeLimiter.
/**
* Invokes search with the specified filter and collector.
* If a time limit has been specified, wrap the collector in a TimeLimitingCollector
*/
private void searchWithTimeLimiter(final Filter luceneFilter, Collector collector) throws IOException {
if (cmd.getTimeAllowed() > 0) {
if (timeLimitingCollector == null) {
timeLimitingCollector = new TimeLimitingCollector(collector, TimeLimitingCollector.getGlobalCounter(), cmd.getTimeAllowed());
} else {
/*
* This is so the same timer can be used for grouping's multiple phases.
* We don't want to create a new TimeLimitingCollector for each phase because that would
* reset the timer for each phase. If time runs out during the first phase, the
* second phase should timeout quickly.
*/
timeLimitingCollector.setCollector(collector);
}
collector = timeLimitingCollector;
}
try {
Query q = query;
if (luceneFilter != null) {
q = new BooleanQuery.Builder().add(q, Occur.MUST).add(luceneFilter, Occur.FILTER).build();
}
searcher.search(q, collector);
} catch (TimeLimitingCollector.TimeExceededException | ExitableDirectoryReader.ExitingReaderException x) {
logger.warn("Query: " + query + "; " + x.getMessage());
qr.setPartialResults(true);
}
}
use of org.apache.lucene.search.TimeLimitingCollector in project elasticsearch-skywalker by jprante.
the class IntervalLimitedCollector method reset.
@Override
public void reset() {
lastDoc = 0;
tdc = TopScoreDocCollector.create(1000, outOfOrder);
thc = new TimeLimitingCollector(tdc, TimeLimitingCollector.getGlobalCounter(), maxTime);
}
use of org.apache.lucene.search.TimeLimitingCollector in project lucene-solr by apache.
the class CommandHandler method searchWithTimeLimiter.
/**
* Invokes search with the specified filter and collector.
* If a time limit has been specified then wrap the collector in the TimeLimitingCollector
*/
private void searchWithTimeLimiter(Query query, ProcessedFilter filter, Collector collector) throws IOException {
if (queryCommand.getTimeAllowed() > 0) {
collector = new TimeLimitingCollector(collector, TimeLimitingCollector.getGlobalCounter(), queryCommand.getTimeAllowed());
}
TotalHitCountCollector hitCountCollector = new TotalHitCountCollector();
if (includeHitCount) {
collector = MultiCollector.wrap(collector, hitCountCollector);
}
if (filter.filter != null) {
query = new BooleanQuery.Builder().add(query, Occur.MUST).add(filter.filter, Occur.FILTER).build();
}
if (filter.postFilter != null) {
filter.postFilter.setLastDelegate(collector);
collector = filter.postFilter;
}
try {
searcher.search(query, collector);
} catch (TimeLimitingCollector.TimeExceededException | ExitableDirectoryReader.ExitingReaderException x) {
partialResults = true;
logger.warn("Query: " + query + "; " + x.getMessage());
}
if (includeHitCount) {
totalHitCount = hitCountCollector.getTotalHits();
}
}
Aggregations