Skip to content

Commit c8b3ba7

Browse files
authored
Restore Search Results Aggregations Explanations Page (#585)
This page was removed in v5.4 for an unknown reason. We currently have a broken link to it; this adds it back to our doc site.
1 parent 26a175c commit c8b3ba7

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Search results aggregations
2+
3+
In version 4.0 and later, Code Insights provides aggregations shown on the search screen.
4+
5+
This lets you track version and license spread, library adoption, common commit messages, lengths of specific files, usage frequencies, and the [many common use case examples here](../references/search_aggregations_use_cases.md).
6+
7+
## Available aggregations:
8+
9+
You can aggregate any search by:
10+
11+
1. The repositories with search results
12+
1. The files with search results (for non-commit and non-diff searches)
13+
1. The authors who created the search results (for commit and diff searches)
14+
1. All found matches for the first capture group pattern (for regexp searches with a capture group)
15+
16+
Aggregations are returned in order of greatest to least results count.
17+
18+
Aggregations are exhaustive across all repositories the user running the search has access to, unless the chart notes otherwise (see [Limitations](#limitations) below).
19+
20+
We may continue adding new aggregation categories, like date and code host, based on feedback. If there are categories you'd like to see, please [let us know](mailto:[email protected]).
21+
22+
## Feature visibility
23+
24+
You can turn the aggregations on with the experimental feature setting: `searchResultsAggregations` in your user, org, or site settings.
25+
26+
You can turn off just the proactive aggregations by setting `proactiveSearchResultsAggregations` to `false`.
27+
This prevents aggregations from running on every search and requires users to explicitly click to run them.
28+
(The main reason to consider disabling proactive aggregations is if you're seeing a heavy or unexpected load on your instance, but as noted below in [Limitations](#limitations) there are limits that keep the overall resource needs low to begin with.)
29+
30+
## Drilldowns
31+
32+
You can drilldown into a search aggregation by clicking a result in the chart. Your original search query will be updated with a `repo`, `file`, `author` filter or a regexp pattern depending on the aggregation mode.
33+
34+
## Limitations
35+
36+
### Mode limitations
37+
38+
If you attempt to run a query for which a given mode is not supported, the tooltip will inform you why that mode is not available.
39+
40+
### Timeout limits
41+
42+
At the moment all aggregations search queries are run with a 2-second timeout, even if your search specified a timeout. If the aggregation times out, you will be able to trigger a longer search with a 1-minute timeout by clicking `Run aggregation`. The extended timeout can be configured by changing the number of seconds in global settings `insights.aggregations.extendedTimeout`. If configuring this to greater than 60 seconds please see [More information on timeouts](../../code_search/how-to/exhaustive.md#timeouts).
43+
44+
After adding new repositories it can be common for aggregations to experience timeouts while those repositories await initial indexing. This is due to aggregations running exhaustive searches over all repositories and will resolve once that indexing is complete.
45+
46+
### Count limits
47+
48+
Aggregation search queries that run proactively are run with `count:50000`. This default can be changed using the site setting `insights.aggregations.proactiveResultLimit`.
49+
If the number of results exceeds this limit, the user can choose to explicitly run the aggregation, and these explicitly-run aggregations use `count:all`.
50+
51+
### Best effort aggregation
52+
53+
Results are aggregated in a best-effort approach using a limited-size buffer to hold group labels in order not to strain the webapp when these aggregations are run.
54+
This means that in some cases we might miss some high-count results.
55+
Aggregations that hit such non-exhaustive paths are reported back to the user.
56+
57+
You can control the size of the buffer using the site setting `insights.aggregations.bufferSize`. It is set to 500 by default. Note that if increasing this you might notice decreased performance on your instance.
58+
59+
### Number of bars displayed
60+
61+
The side panel will display a maximum of 10 bars. If expanded, a maximum of 30 bars will be displayed. If there are more results this will be displayed on the panel.
62+
63+
### Single capture group
64+
65+
Aggregations by capture group will match on the first capture group in the search query only. For example, for a query:
66+
67+
```sgquery
68+
hello-(\w+)-(\w+)
69+
```
70+
71+
and a match like `hello-beautiful-world` only `beautiful` will be shown as a result.
72+
73+
### Files with the same paths in distinct repositories
74+
75+
The "file" aggregation groups only by path, not by repository, meaning files with the same path but from different repos will be grouped together. Attach a `repo:` filter to your search to focus on a specific repo.
76+
77+
### Saving aggregations to a code insights dashboard
78+
79+
Saving aggregations to a dashboard of code insights is not yet available.
80+
81+
### Slower diff and commit queries
82+
83+
Running aggregations by author is only allowed for `type:diff` and `type:commit` queries, which are likely not to complete within a 2-second timeout.
84+
You can trigger an explicit search with an extended 1-minute timeout, or you can limit your query using a single-repo filter (like `repo:^github\.com/sourcegraph/sourcegraph$`) combined with a `before` or `after` filter.
85+
86+
### Structural searches
87+
88+
Aggregations for structural searches are unlikely to complete within a 2-second timeout. You can try to trigger an explicit aggregation for such cases.
89+
90+
### Standard searches with embedded regexp
91+
92+
Standard searches with embedded regexp such as below do not support aggregation by capture group. This is because they are functionally similar to a query with an `or` operator.
93+
```sgquery
94+
database /(\w+)/
95+
```

0 commit comments

Comments
 (0)