insights: add ability to extend timeout for aggregations
Created by: chwarwick
Adds the ability to extend the timeout for an aggregation to complete.
Also cleans up the returned messages for timeouts and adds a new returned reasonType for when an aggregation doesn't complete that holds the category of reason so that clients can use that to determine what action to take. The need for this is to give a clear signal to a client of why the aggregation failed and to be able to determine if it's possible to retry with the extended timeout.
Test plan
Updated unit tests request:
{
searchQueryAggregate(query: "go\\s*(\\d\\.\\d+)", patternType: regexp) {
aggregations(mode: CAPTURE_GROUP, limit: 10) {
__typename
... on SearchAggregationNotAvailable {
reason
reasonType
}
}
}
}
response:
{
"data": {
"searchQueryAggregate": {
"aggregations": {
"__typename": "SearchAggregationNotAvailable",
"reason": "We couldn't provide an aggregation for this query. The query was unable to complete in the allocated time.",
"reasonType": "TIMEOUT_EXTENSION_AVAILABLE"
}
}
}
}
With timeout extension:
{
searchQueryAggregate(query: "go\\s*(\\d\\.\\d+)", patternType: regexp) {
aggregations(mode: CAPTURE_GROUP, limit: 2, extendedTimeout:true) {
__typename
... on ExhaustiveSearchAggregationResult {
groups {
label
count
query
}
otherResultCount
otherGroupCount
}
... on SearchAggregationNotAvailable {
reason
reasonType
}
}
}
}
response:
{
"data": {
"searchQueryAggregate": {
"aggregations": {
"__typename": "ExhaustiveSearchAggregationResult",
"groups": [
{
"label": "1.16",
"count": 493,
"query": "/go\\s*(?:1\\.16)/"
},
{
"label": "1.13",
"count": 307,
"query": "/go\\s*(?:1\\.13)/"
}
],
"otherResultCount": 2541,
"otherGroupCount": 37
}
}
}
}