Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add completion_time time field to async_search get and status response #97700

Merged
merged 5 commits into from
Jul 17, 2023
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
6 changes: 6 additions & 0 deletions docs/changelog/97700.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 97700
summary: Add `completion_time` time field to `async_search` get and status response
area: Search
type: enhancement
issues:
- 88640
20 changes: 12 additions & 8 deletions docs/reference/search/async-search.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ search results are returned as part of the
// TESTRESPONSE[s/"is_running" : true/"is_running": $body.is_running/]
// TESTRESPONSE[s/1583945890986/$body.start_time_in_millis/]
// TESTRESPONSE[s/1584377890986/$body.expiration_time_in_millis/]
// TESTRESPONSE[s/"response"/"completion_time_in_millis": $body.completion_time_in_millis,\n "response"/]
// TESTRESPONSE[s/"took" : 1122/"took": $body.response.took/]
// TESTRESPONSE[s/"num_reduce_phases" : 0,//]
// TESTRESPONSE[s/"total" : 562/"total": $body.response._shards.total/]
Expand Down Expand Up @@ -156,17 +157,18 @@ GET /_async_search/FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsd
--------------------------------------------------
{
"id" : "FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=",
"is_partial" : true, <1>
"is_running" : true, <2>
"is_partial" : false, <1>
"is_running" : false, <2>
"start_time_in_millis" : 1583945890986,
"expiration_time_in_millis" : 1584377890986, <3>
"completion_time_in_millis" : 1583945903130, <4>
"response" : {
"took" : 12144,
"timed_out" : false,
"num_reduce_phases" : 46, <4>
"num_reduce_phases" : 46, <5>
"_shards" : {
"total" : 562,
"successful" : 188, <5>
"successful" : 188, <6>
"skipped" : 0,
"failed" : 0
},
Expand All @@ -178,7 +180,7 @@ GET /_async_search/FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsd
"max_score" : null,
"hits" : [ ]
},
"aggregations" : { <6>
"aggregations" : { <7>
"sale_date" : {
"buckets" : []
}
Expand All @@ -191,6 +193,7 @@ GET /_async_search/FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsd
// TESTRESPONSE[s/"is_running" : true/"is_running" : false/]
// TESTRESPONSE[s/1583945890986/$body.start_time_in_millis/]
// TESTRESPONSE[s/1584377890986/$body.expiration_time_in_millis/]
// TESTRESPONSE[s/1583945903130/$body.completion_time_in_millis/]
// TESTRESPONSE[s/"took" : 12144/"took": $body.response.took/]
// TESTRESPONSE[s/"total" : 562/"total": $body.response._shards.total/]
// TESTRESPONSE[s/"successful" : 188/"successful": $body.response._shards.successful/]
Expand All @@ -203,13 +206,14 @@ or was successfully completed on all shards. While the query is being
executed, `is_partial` is always set to `true`
<2> Whether the search is still being executed or it has completed
<3> When the async search will expire
<4> Indicates how many reductions of the results have been performed. If this
<4> When the async search has finished, the completion_time is indicated (start_time + took)
<5> Indicates how many reductions of the results have been performed. If this
number increases compared to the last retrieved results, you can expect
additional results included in the search response
<5> Indicates how many shards have executed the query. Note that in order for
<6> Indicates how many shards have executed the query. Note that in order for
shard results to be included in the search response, they need to be reduced
first.
<6> Partial aggregations results, coming from the shards that have already
<7> Partial aggregations results, coming from the shards that have already
completed the execution of the query.

The `wait_for_completion_timeout` parameter can also be provided when calling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ The API returns the following response:
// TESTRESPONSE[s/"is_running": true/"is_running": $body.is_running/]
// TESTRESPONSE[s/1685563581380/$body.start_time_in_millis/]
// TESTRESPONSE[s/1685995581380/$body.expiration_time_in_millis/]
// TESTRESPONSE[s/"response"/"completion_time_in_millis": $body.completion_time_in_millis,\n "response"/]
// TESTRESPONSE[s/"num_reduce_phases": 0/"num_reduce_phases": "$body.response.num_reduce_phases"/]
// TESTRESPONSE[s/"took": 1020/"took": "$body.response.took"/]
// TESTRESPONSE[s/"total": 8/"total": $body.response._shards.total/]
Expand Down Expand Up @@ -465,19 +466,20 @@ Response:
"is_running": false,
"start_time_in_millis": 1685564911108,
"expiration_time_in_millis": 1685996911108,
"completion_time_in_millis": 1685564938727, <1>
"response": {
"took": 27619,
"timed_out": false,
"num_reduce_phases": 4,
"_shards": {
"total": 28,
"successful": 28, <1>
"successful": 28, <2>
"skipped": 0,
"failed": 0
},
"_clusters": {
"total": 3,
"successful": 3, <2>
"successful": 3, <3>
"skipped": 0
},
"hits": {
Expand All @@ -496,6 +498,7 @@ Response:
// TESTRESPONSE[s/"is_running": true/"is_running": $body.is_running/]
// TESTRESPONSE[s/1685564911108/$body.start_time_in_millis/]
// TESTRESPONSE[s/1685996911108/$body.expiration_time_in_millis/]
// TESTRESPONSE[s/1685564938727/$body.completion_time_in_millis/]
// TESTRESPONSE[s/"took": 27619/"took": "$body.response.took"/]
// TESTRESPONSE[s/"total": 28/"total": $body.response._shards.total/]
// TESTRESPONSE[s/"successful": 28/"successful": $body.response._shards.successful/]
Expand All @@ -506,9 +509,10 @@ Response:
// TESTRESPONSE[s/"hits": \[...list of hits here...\]/"hits": $body.response.hits.hits/]


<1> The `_shards` section is now updated to show that 28 total shards
<1> Once the search has finished, the completion_time is present.
<2> The `_shards` section is now updated to show that 28 total shards
were searched across all clusters and that all were successful.
<2> The `_clusters` section shows that searches on all 3 clusters were successful.
<3> The `_clusters` section shows that searches on all 3 clusters were successful.



Expand Down Expand Up @@ -592,6 +596,7 @@ the `wait_for_completion_timeout` duration (see <<async-search>>).
// TESTRESPONSE[s/"is_running": true/"is_running": $body.is_running/]
// TESTRESPONSE[s/1685563581380/$body.start_time_in_millis/]
// TESTRESPONSE[s/1685995581380/$body.expiration_time_in_millis/]
// TESTRESPONSE[s/"response"/"completion_time_in_millis": $body.completion_time_in_millis,\n "response"/]
// TESTRESPONSE[s/"num_reduce_phases": 0/"num_reduce_phases": "$body.response.num_reduce_phases"/]
// TESTRESPONSE[s/"took": 1020/"took": "$body.response.took"/]
// TESTRESPONSE[s/"total": 28/"total": $body.response._shards.total/]
Expand Down
3 changes: 2 additions & 1 deletion server/src/main/java/org/elasticsearch/TransportVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ private static TransportVersion registerTransportVersion(int id, String uniqueId
public static final TransportVersion V_8_500_032 = registerTransportVersion(8_500_032, "a9a14bc6-c3f2-41d9-a3d8-c686bf2c901d");
public static final TransportVersion V_8_500_033 = registerTransportVersion(8_500_033, "193ab7c4-a751-4cbd-a66a-2d7d56ccbc10");
public static final TransportVersion V_8_500_034 = registerTransportVersion(8_500_034, "16871c8b-88ba-4432-980a-10fd9ecad2dc");
public static final TransportVersion V_8_500_035 = registerTransportVersion(8_500_035, "664dd6ce-3487-4fbd-81a9-af778b28be45");

private static class CurrentHolder {
private static final TransportVersion CURRENT = findCurrent(V_8_500_034);
private static final TransportVersion CURRENT = findCurrent(V_8_500_035);

// finds the pluggable current version, or uses the given fallback
private static TransportVersion findCurrent(TransportVersion fallback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ synchronized AsyncSearchResponse toAsyncSearchResponse(AsyncSearchTask task, lon
} else {
/*
* Build the response, reducing aggs if we haven't already and
* storing the result of the reduction so we won't have to reduce
* storing the result of the reduction, so we won't have to reduce
* the same aggregation results a second time if nothing has changed.
* This does cost memory because we have a reference to the finally
* reduced aggs sitting around which can't be GCed until we get an update.
Expand Down Expand Up @@ -253,6 +253,7 @@ synchronized AsyncStatusResponse toStatusResponse(String asyncExecutionId, long
false,
startTime,
expirationTime,
startTime + finalResponse.getTook().millis(),
finalResponse.getTotalShards(),
finalResponse.getSuccessfulShards(),
finalResponse.getSkippedShards(),
Expand All @@ -268,6 +269,7 @@ synchronized AsyncStatusResponse toStatusResponse(String asyncExecutionId, long
true,
startTime,
expirationTime,
null,
totalShards,
successfulShards,
skippedShards,
Expand All @@ -282,6 +284,7 @@ synchronized AsyncStatusResponse toStatusResponse(String asyncExecutionId, long
true,
startTime,
expirationTime,
null,
totalShards,
successfulShards,
skippedShards,
Expand Down
Loading