insights: Don't return an error when checking for default mode on a standard query
Created by: CristinaBirkel
Description
When getting a default aggregation mode, canAggregateByCaptureGroup
is calling NewPatternReplacer
to check to see if there are any capture groups. NewPatternReplacer
returns errors if it isn't a regexp
, and we don't want to throw an error on that if we're just using it to check for capture groups.
So the solution here is to check specifically for that error, and to return false
instead of an error when it's hit.
Test plan
First, run a standard query that will check for the default mode. Example:
{
searchQueryAggregate(query: "graphql.NewSchema", patternType: standard) {
aggregations(limit: 10) {
__typename
... on ExhaustiveSearchAggregationResult {
groups {
label
count
query
}
otherResultCount
otherGroupCount
}
... on SearchAggregationNotAvailable {
reason
}
}
}
}
Verify that you get a "pattern parsing" error. Then try again with this fix in place and verify that it works.