Helix TeamHub supports code searching for Mercurial, Git, and Helix Git repositories.
The code is indexed from each repository's default branch. You can configure the default branch for each repository from the repository settings view.
Code search can be performed on the following levels:
- Company level (all repositories within the company)
- Project level (all repositories within one or multiple projects)
- Repository level (one or multiple repositories)
You must have company administrator privileges to enable code search.
On-premise customers will first need to setup and configure Elasticsearch to their Helix TeamHub instance. Refer to the administrator's guide on how to achieve this. If you require further assistance, please don't hesitate to contact support.
To enable code search:
Access the Company Settings view using the user dropdown list in the header or from the My Dashboard tab.
In the Features tab, turn on Code Search and click Save.
Once code search is enabled, TeamHub indexes all repositories within the company. Depending on the amount of data to process, the indexing operation might take a while. You can monitor the current progress on the My Dashboard tab. When done, the indicator on the right displays Indexing complete.
For information on other features that company admins can configure, see Feature settings.
You can begin a code search from any view. To search the code:
Click the search icon in the site header.
In the search field, enter your search term and press Enter.
TeamHub displays the search results in a separate view.
By default, TeamHub displays only the matching code lines.
To view the full search context, click the arrow icon beneath the result.
To see more results, use the pagination controls at the bottom of the page.
You can limit code searches to a path, a filename, or a filename in a path by entering your search term followed by the path, filename, or path and filename.
More than one path and filename can be entered for a search term.
For example, String.prototype.includes path:app/utilities followed by Enter, TeamHub creates the path as a tag:
Wildcards are supported in the path.
For example, String.prototype.includes filename:test.js followed by Enter, TeamHub creates the filename as a tag:
The filename is only searched if an exact match is found. Wildcards are not supported for filenames.
For example, String.prototype.includes filename:test.js path:app/utilities followed by Enter, TeamHub creates the filename as a tag and path as a tag:
The filename is only searched if an exact match is found and the filename is in the path. Wildcards are not supported for filenames.
You can use special characters to make your results more relevant.
To search for an exact match, surround your search term with quotes ". For example, to find results that exactly match String.prototype.includes enter the following search term:
In most cases, wrapping your search term in quotes will result in exact matches for your search query. However, due to the way that Elasticsearch indexes and creates its "phrase query" for your search term, it can result in unexpected search results.
For example: searching for "String.prototype.includes" could result in the following being displayed in the search results:
- String.prototype.includes - expected
- String.PrototypeObject.includes - not expected
- StringTheory.prototype.includes - not expected
To find results that contain term-x and term-y, separate your search terms with a space. For example, to find results that contain String and prototype enter the following search term:
To find results that contain term-x, term-y, or both, separate your search terms with a pipe | character. For example, to find results that contain String, prototype, or both enter the following search term:
String | prototype
To find results that contain term-x but exclude those that also contain term-y, use the minus - character in front of the term you want to exclude it. For example, to find results that contain String but not prototype enter the following search term:
You can narrow down search results by specifying which projects and repositories to include.
Helix TeamHub applies the following filters automatically based on the view from which you invoke the search:
- Browsing a project sets the current project as the filter.
- Browsing repository views or the project's wiki sets the repository as the filter.
You can clear these filters in the results view.
Invoking a search from the company scope does not set any filters. Instead, TeamHub searches within all projects and repositories to which you have access. To make sure you are at the company scope level, click the company name or logo in the top left corner.
In addition to the project and repository filters, you can define whether to include or omit results from forked repositories using the dropdown list on the right.
The numbers next to the filters indicate the number of results for each project and repository. Note that by selecting a project, you are effectively searching in all repositories within that project. To restrict the search to specific repositories, first remove the project filter.
If you have multiple repositories with the same name in several projects, you can narrow down the search using the following syntax:
project:repository. For example, to search repositories starting with
bat in a project called
Amazing, enter the following string in the search field: amazing:bat
To view a project's identifier, go to the Projects tab or move your pointer over the project name.