Skip to content

Commit a71195a

Browse files
committed
iter
1 parent 03ec1f4 commit a71195a

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

server/src/main/java/org/elasticsearch/search/profile/SearchProfileCoordinatorResult.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
public class SearchProfileCoordinatorResult implements Writeable, ToXContentFragment {
2828

2929
private final String nodeId;
30+
private long tookInMillis;
3031
private final RetrieverProfileResult retrieverProfileResult;
3132
private final Map<String, Long> breakdownMap;
3233

@@ -38,13 +39,15 @@ public SearchProfileCoordinatorResult(String nodeId, RetrieverProfileResult retr
3839

3940
public SearchProfileCoordinatorResult(StreamInput in) throws IOException {
4041
nodeId = in.readString();
42+
tookInMillis = in.readLong();
4143
retrieverProfileResult = in.readOptionalWriteable(RetrieverProfileResult::new);
4244
breakdownMap = in.readMap(StreamInput::readString, StreamInput::readLong);
4345
}
4446

4547
@Override
4648
public void writeTo(StreamOutput out) throws IOException {
4749
out.writeString(nodeId);
50+
out.writeLong(tookInMillis);
4851
out.writeOptionalWriteable(retrieverProfileResult);
4952
out.writeMap(breakdownMap, StreamOutput::writeString, StreamOutput::writeLong);
5053
}
@@ -53,13 +56,16 @@ public String getNodeId() {
5356
return this.nodeId;
5457
}
5558

56-
public RetrieverProfileResult getRetrieverProfileResult() {
57-
return this.retrieverProfileResult;
59+
public void setTookInMillis(long tookInMillis) {
60+
this.tookInMillis = tookInMillis;
5861
}
5962

6063
@Override
6164
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
6265
builder.field("node_id", nodeId);
66+
if (tookInMillis != -1) {
67+
builder.field("took_in_millis", tookInMillis);
68+
}
6369
if (retrieverProfileResult != null) {
6470
builder.field("retriever", retrieverProfileResult);
6571
}
@@ -75,13 +81,14 @@ public boolean equals(Object o) {
7581
if (o == null || getClass() != o.getClass()) return false;
7682
SearchProfileCoordinatorResult that = (SearchProfileCoordinatorResult) o;
7783
return nodeId.equals(that.nodeId)
84+
&& tookInMillis == that.tookInMillis
7885
&& Objects.equals(retrieverProfileResult, that.retrieverProfileResult)
7986
&& Objects.equals(breakdownMap, that.breakdownMap);
8087
}
8188

8289
@Override
8390
public int hashCode() {
84-
return Objects.hash(nodeId, retrieverProfileResult, breakdownMap);
91+
return Objects.hash(nodeId, tookInMillis, retrieverProfileResult, breakdownMap);
8592
}
8693

8794
@Override

server/src/main/java/org/elasticsearch/search/retriever/CompoundRetrieverBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public void onResponse(MultiSearchResponse items) {
153153
listener.onFailure(new IllegalStateException("Coordinator profile results are missing"));
154154
}
155155
SearchProfileCoordinatorResult nestedResult = item.getResponse().getCoordinatorProfileResults();
156-
nestedResult.getRetrieverProfileResult().setTookInMillis(item.getResponse().getTookInMillis());
156+
nestedResult.setTookInMillis(item.getResponse().getTookInMillis());
157157
profiler.captureInnerRetrieverResult(innerRetrievers.get(i).retriever().getName(), nestedResult);
158158
}
159159
}

server/src/test/java/org/elasticsearch/action/search/RankFeaturePhaseTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,8 @@ public ScoreDoc[] rankQueryPhaseResults(
900900
) {
901901
List<ScoreDoc> docScores = new ArrayList<>();
902902
for (QuerySearchResult phaseResults : rankSearchResults) {
903-
docScores.addAll(Arrays.asList(phaseResults.topDocs().topDocs.scoreDocs));
903+
assert phaseResults.getRankShardResult() != null;
904+
docScores.addAll(Arrays.asList(((RankFeatureShardResult) phaseResults.getRankShardResult()).rankFeatureDocs));
904905
}
905906
ScoreDoc[] sortedDocs = docScores.toArray(new ScoreDoc[0]);
906907
// negating scores

0 commit comments

Comments
 (0)