aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java')
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java17
1 files changed, 14 insertions, 3 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java b/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java
index 083de083108..12f8cdf9852 100644
--- a/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.cluster;
import com.yahoo.component.annotation.Inject;
@@ -244,13 +244,24 @@ public class ClusterSearcher extends Searcher {
throw new IllegalStateException("perSchemaSearch must always be called with 1 schema, got: " + restrict.size());
}
String schema = restrict.iterator().next();
- boolean useGlobalPhase = globalPhaseRanker != null;
+ int rerankCount = globalPhaseRanker != null ? globalPhaseRanker.getRerankCount(query, schema) : 0;
+ boolean useGlobalPhase = rerankCount > 0;
+ final int wantOffset = query.getOffset();
+ final int wantHits = query.getHits();
if (useGlobalPhase) {
var error = globalPhaseRanker.validateNoSorting(query, schema).orElse(null);
if (error != null) return new Result(query, error);
+ int useHits = Math.max(wantOffset + wantHits, rerankCount);
+ query.setOffset(0);
+ query.setHits(useHits);
}
Result result = searcher.search(query, execution);
- if (useGlobalPhase) globalPhaseRanker.rerankHits(query, result, schema);
+ if (useGlobalPhase) {
+ globalPhaseRanker.rerankHits(query, result, schema);
+ result.hits().trim(wantOffset, wantHits);
+ query.setOffset(wantOffset);
+ query.setHits(wantHits);
+ }
return result;
}