lucene 4: Upgraded ContentIndexSearcher
This commit is contained in:
parent
b3e59d58e4
commit
03a16ac7d8
|
@ -22,6 +22,7 @@ package org.elasticsearch.search.internal;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.elasticsearch.common.lucene.MinimumScoreCollector;
|
||||
|
@ -132,25 +133,8 @@ public class ContextIndexSearcher extends IndexSearcher {
|
|||
return super.createNormalizedWeight(query);
|
||||
}
|
||||
|
||||
// override from the Searcher to allow to control if scores will be tracked or not
|
||||
// LUCENE MONITOR - We override the logic here to apply our own flags for track scores
|
||||
@Override
|
||||
public TopFieldDocs search(Weight weight, Filter filter, int nDocs,
|
||||
Sort sort, boolean fillFields) throws IOException {
|
||||
int limit = reader.maxDoc();
|
||||
if (limit == 0) {
|
||||
limit = 1;
|
||||
}
|
||||
nDocs = Math.min(nDocs, limit);
|
||||
|
||||
TopFieldCollector collector = TopFieldCollector.create(sort, nDocs,
|
||||
fillFields, searchContext.trackScores(), searchContext.trackScores(), !weight.scoresDocsOutOfOrder());
|
||||
search(weight, filter, collector);
|
||||
return (TopFieldDocs) collector.topDocs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void search(Weight weight, Filter filter, Collector collector) throws IOException {
|
||||
public void search(Query query, Filter filter, Collector collector) throws IOException {
|
||||
if (searchContext.parsedFilter() != null && Scopes.MAIN.equals(processingScope)) {
|
||||
// this will only get applied to the actual search collector and not
|
||||
// to any scoped collectors, also, it will only be applied to the main collector
|
||||
|
@ -186,12 +170,12 @@ public class ContextIndexSearcher extends IndexSearcher {
|
|||
// we only compute the doc id set once since within a context, we execute the same query always...
|
||||
if (searchContext.timeoutInMillis() != -1) {
|
||||
try {
|
||||
super.search(weight, combinedFilter, collector);
|
||||
super.search(query, combinedFilter, collector);
|
||||
} catch (TimeLimitingCollector.TimeExceededException e) {
|
||||
searchContext.queryResult().searchTimedOut(true);
|
||||
}
|
||||
} else {
|
||||
super.search(weight, combinedFilter, collector);
|
||||
super.search(query, combinedFilter, collector);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,8 @@ public class QueryPhase implements SearchPhase {
|
|||
} else if (searchContext.searchType() == SearchType.SCAN) {
|
||||
topDocs = searchContext.scanContext().execute(searchContext);
|
||||
} else if (searchContext.sort() != null) {
|
||||
topDocs = searchContext.searcher().search(query, null, numDocs, searchContext.sort());
|
||||
topDocs = searchContext.searcher().search(query, null, numDocs, searchContext.sort(),
|
||||
searchContext.trackScores(), searchContext.trackScores());
|
||||
} else {
|
||||
topDocs = searchContext.searcher().search(query, numDocs);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue