Skip to content

Commit

Permalink
iter
Browse files Browse the repository at this point in the history
  • Loading branch information
pmpailis committed Nov 7, 2024
1 parent 3cf0ad5 commit 711a5b6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ static TransportVersion def(int id) {
public static final TransportVersion ESQL_CCS_EXEC_INFO_WITH_FAILURES = def(8_783_00_0);
public static final TransportVersion LOGSDB_TELEMETRY = def(8_784_00_0);
public static final TransportVersion LOGSDB_TELEMETRY_STATS = def(8_785_00_0);
public static final TransportVersion INNER_HITS_DISABLED_FOR_REQUEST = def(8_786_00_0);

/*
* STOP! READ THIS FIRST! No, really,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,12 @@ public String toString() {

public abstract IdLoader newIdLoader();

/**
* Specify whether we should load innerHits for this request or not.
* This is useful for nested retrievers, where we don't want to compute inner hits for nested results
* that won't actually be used.
* Instead, we only compute inner hits for the top-level compound retriever.
*/
public boolean innerHitsDisabled() {
return request() != null && request().innerHitsDisabled();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public ShardSearchRequest(StreamInput in) throws IOException {
*/
forceSyntheticSource = false;
}
if (in.getTransportVersion().onOrAfter(TransportVersion.current())) {
if (in.getTransportVersion().onOrAfter(TransportVersions.INNER_HITS_DISABLED_FOR_REQUEST)) {
innerHitsDisabled = in.readBoolean();
} else {
innerHitsDisabled = false;
Expand Down Expand Up @@ -409,7 +409,7 @@ protected final void innerWriteTo(StreamOutput out, boolean asKey) throws IOExce
throw new IllegalArgumentException("force_synthetic_source is not supported before 8.4.0");
}
}
if (out.getTransportVersion().onOrAfter(TransportVersion.current())) {
if (out.getTransportVersion().onOrAfter(TransportVersions.INNER_HITS_DISABLED_FOR_REQUEST)) {
out.writeBoolean(innerHitsDisabled);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ public void extractToSearchSourceBuilder(SearchSourceBuilder searchSourceBuilder
if (searchSourceBuilder.size() + searchSourceBuilder.from() > rankDocResults.length) {
searchSourceBuilder.size(Math.max(0, rankDocResults.length - searchSourceBuilder.from()));
}
if (compoundUsed) {
searchSourceBuilder.innerHitsDisabled(true);
}
}

private boolean hasAggregations(SearchSourceBuilder searchSourceBuilder) {
Expand Down

0 comments on commit 711a5b6

Please sign in to comment.