insights: generate drilldown queries for aggregation matches
Created by: coury-clark
Closes https://github.com/sourcegraph/sourcegraph/issues/40370
Generate drilldown queries (to get more specific) for aggregation match groups. If the drilldown query cannot be generated, fallback to the original query.
This has some rough areas (for example lots of repeated / duplicated query parsing). I have a query builder refactor I'm working on the side to clean this up and improve it. That said this functionality isn't blocked by that refactor.
Additionally, I believe the capture group aggregation isn't implemented yet, so obviously will need to wait to try out on that.
One note about author drilldown - it seems that we may need to escape for whitespace as well as regexp characters, as whitespace will cause the query to change semantics and break. For example if the match is Santa Claus
and it tries to generate author:Santa Claus
, actually it needs author:Santa\ Claus
Test plan
Tested manually for repo / filter / author. Will circle back to this for tests when the functionality is implemented.