Advanced Search: Allow custom prefix for index names
What does this MR do and why?
This MR introduces a configurable elasticsearch_prefix setting that allows administrators to customize the prefix used for Elasticsearch index names. Previously, index names were hardcoded to use 'gitlab' as the prefix (e.g., gitlab-production-issues). Now administrators can specify a custom prefix through the elasticsearch_prefix application setting.
This enhancement enables better index organization in multi-tenant or multi-environment setups where multiple GitLab instances share the same Elasticsearch cluster, allowing each instance to use distinct index prefixes.
Note
This setting does not have an input in the Admin UI since it should only be used when multiple GitLab instances use the same Elasticsearch/OpenSearch cluster. SM admins can update it using rails console.
References
Screenshots or screen recordings
N/A - This is a backend configuration change with no UI modifications.
How to set up and validate locally
- Enable Elasticsearch in your GitLab instance if not already enabled
- Update the "Index prefix" field with a custom value (e.g.,
my-custom-prefix) via the rails consoleGitlab::CurrentSettings.update!(elasticsearch_prefix: 'gl') - Re-index the instance
- Run the rake task to view current Elasticsearch configuration:
bundle exec rake gitlab:elastic:info - Verify that the output shows your custom prefix under "Prefix:"
- Verify that new indices use your custom prefix:
You should see indices prefixed with your custom value instead of
curl -X GET "localhost:9200/_cat/indices?v"gitlab
Key Changes
-
Application Setting: Added
elasticsearch_prefixsetting with default value'gitlab' -
Index Configuration: Updated all Elasticsearch config classes (
CommitConfig,EpicConfig,IssueConfig, etc.) to use dynamic index naming - Reference Utils: Modified reference utilities to use the configurable prefix
- Documentation: Updated API documentation and Advanced Search documentation
- Test Coverage: Added comprehensive specs for the new functionality
- Rake Task Enhancement: Enhanced info display to show the configured prefix
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #3421 (closed)