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

  1. Enable Elasticsearch in your GitLab instance if not already enabled
  2. Update the "Index prefix" field with a custom value (e.g., my-custom-prefix) via the rails console
    Gitlab::CurrentSettings.update!(elasticsearch_prefix: 'gl')
  3. Re-index the instance
  4. Run the rake task to view current Elasticsearch configuration:
    bundle exec rake gitlab:elastic:info
  5. Verify that the output shows your custom prefix under "Prefix:"
  6. Verify that new indices use your custom prefix:
    curl -X GET "localhost:9200/_cat/indices?v"
    You should see indices prefixed with your custom value instead of gitlab

Key Changes

  • Application Setting: Added elasticsearch_prefix setting 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)

Edited by Dmitry Gruzd

Merge request reports

Loading