Skip to content

insights: move aggregations to search client away from api

Administrator requested to merge cw/aggregations-search-client into main

Created by: chwarwick

Switch aggregation search logic to using the search client instead of the api so that chunk matches are populated and can be used for capture group processing. Also moved the aggregation logic out of the stream search package into it's own.

resolves https://github.com/sourcegraph/sourcegraph/issues/40576

Test plan

Updated unit tests

Manual api tests verifying counts match previous results using search API:

{
  searchQueryAggregate(query: "context:global worker", patternType: lucky) {
    aggregations(mode: REPO, limit: 10) {
      __typename
      ... on ExhaustiveSearchAggregationResult {
        groups {
          label
          count
          query
        }
        otherResultCount
        otherGroupCount
      }
      ... on SearchAggregationNotAvailable {
        reason
      }
    }
  }
}

response

{
  "data": {
    "searchQueryAggregate": {
      "aggregations": {
        "__typename": "ExhaustiveSearchAggregationResult",
        "groups": [
          {
            "label": "github.com/sgtest/megarepo",
            "count": 38500,
            "query": null
          },
          {
            "label": "github.com/sourcegraph/sourcegraph",
            "count": 6604,
            "query": null
          },
          {
            "label": "github.com/sourcegraph-testing/etcd",
            "count": 13,
            "query": null
          }
        ],
        "otherResultCount": 0,
        "otherGroupCount": 0
      }
    }
  }
}

Merge request reports

Loading