Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
import java.util.function.Function;
import java.util.stream.Collectors;

import static org.apache.lucene.search.ScoreMode.COMPLETE;
import static org.apache.lucene.search.ScoreMode.TOP_DOCS;
import static org.apache.lucene.search.ScoreMode.TOP_DOCS_WITH_SCORES;

/**
* Source operator that builds Pages out of the output of a TopFieldCollector (aka TopN)
Expand All @@ -65,7 +65,7 @@ public Factory(
List<SortBuilder<?>> sorts,
boolean scoring
) {
super(contexts, queryFunction, dataPartitioning, taskConcurrency, limit, scoring ? COMPLETE : TOP_DOCS);
super(contexts, queryFunction, dataPartitioning, taskConcurrency, limit, scoring ? TOP_DOCS_WITH_SCORES : TOP_DOCS);
this.maxPageSize = maxPageSize;
this.sorts = sorts;
}
Expand Down Expand Up @@ -287,7 +287,7 @@ PerShardCollector newPerShardCollector(ShardContext shardContext, List<SortBuild
SortField[] sortFields = sortAndFormats.get().sort.getSort();
if (sortFields != null && sortFields.length == 1 && sortFields[0].needsScores() && sortFields[0].getReverse() == false) {
// SORT _score DESC
return new ScoringPerShardCollector(shardContext, new TopScoreDocCollectorManager(limit, null, limit).newCollector());
return new ScoringPerShardCollector(shardContext, new TopScoreDocCollectorManager(limit, null, 0).newCollector());
} else {
// SORT ..., _score, ...
var sort = new Sort();
Expand All @@ -297,7 +297,7 @@ PerShardCollector newPerShardCollector(ShardContext shardContext, List<SortBuild
l.add(SortField.FIELD_SCORE);
sort = new Sort(l.toArray(SortField[]::new));
}
return new ScoringPerShardCollector(shardContext, new TopFieldCollectorManager(sort, limit, null, limit).newCollector());
return new ScoringPerShardCollector(shardContext, new TopFieldCollectorManager(sort, limit, null, 0).newCollector());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,16 @@ public Optional<SortAndFormats> buildSort(List<SortBuilder<?>> sorts) {
@Override
protected Matcher<String> expectedToStringOfSimple() {
return matchesRegex(
"LuceneTopNSourceOperator\\[shards = \\[test], maxPageSize = \\d+, limit = 100, scoreMode = COMPLETE, sorts = \\[\\{.+}]]"
"LuceneTopNSourceOperator\\[shards = \\[test], "
+ "maxPageSize = \\d+, limit = 100, scoreMode = TOP_DOCS_WITH_SCORES, sorts = \\[\\{.+}]]"
);
}

@Override
protected Matcher<String> expectedDescriptionOfSimple() {
return matchesRegex(
"LuceneTopNSourceOperator"
+ "\\[dataPartitioning = (DOC|SHARD|SEGMENT), maxPageSize = \\d+, limit = 100, scoreMode = COMPLETE, sorts = \\[\\{.+}]]"
"LuceneTopNSourceOperator\\[dataPartitioning = (DOC|SHARD|SEGMENT), "
+ "maxPageSize = \\d+, limit = 100, scoreMode = TOP_DOCS_WITH_SCORES, sorts = \\[\\{.+}]]"
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ public Optional<SortAndFormats> buildSort(List<SortBuilder<?>> sorts) {

@Override
protected Matcher<String> expectedToStringOfSimple() {
var s = scoring ? "COMPLETE" : "TOP_DOCS";
var s = scoring ? "TOP_DOCS_WITH_SCORES" : "TOP_DOCS";
return matchesRegex(
"LuceneTopNSourceOperator\\[shards = \\[test], maxPageSize = \\d+, limit = 100, scoreMode = " + s + ", sorts = \\[\\{.+}]]"
);
}

@Override
protected Matcher<String> expectedDescriptionOfSimple() {
var s = scoring ? "COMPLETE" : "TOP_DOCS";
var s = scoring ? "TOP_DOCS_WITH_SCORES" : "TOP_DOCS";
return matchesRegex(
"LuceneTopNSourceOperator"
+ "\\[dataPartitioning = (DOC|SHARD|SEGMENT), maxPageSize = \\d+, limit = 100, scoreMode = "
Expand Down