Skip to content

Elasticsearch connection string scope key has no effect on index names #2696

Closed as not planned

Description

@ejsmith

ElasticsearchOptions parses a scope key from ConnectionStrings:Elasticsearch, but index names are built from ScopePrefix, which is computed from AppScope before the connection string is parsed. Setting scope= in the Elasticsearch connection string changes nothing.

Where

  • ElasticsearchOptions.ReadFromConfiguration sets Scope = appOptions.AppScope and ScopePrefix from it, then calls ParseConnectionString.
  • ParseConnectionString overwrites Scope from the scope key but never recomputes ScopePrefix.
  • Every index uses ScopePrefix, e.g. EventIndex and the migrations index. Nothing reads ElasticsearchOptions.Scope for the main cluster.
  • The only reader of Scope is DataMigrationJob, for ElasticsearchToMigrate, where it is used as a raw prefix with no - separator (scope=prod gives prodorganizations-v1, while the main cluster's prefix would be prod-).

Steps to reproduce

  1. Run with EX_ConnectionStrings__Elasticsearch=server=http://localhost:9200;scope=test and no EX_AppScope.
  2. List indexes: they are events-v1-*, stacks-v1, organizations-v1, etc., without a test- prefix.

Expected

Either scope in the Elasticsearch connection string prefixes index names the same way AppScope does, or the key is not parsed at all.

Suggested fix

Set ScopePrefix at the end of ParseConnectionString (ScopePrefix = String.IsNullOrEmpty(Scope) ? "" : $"{Scope}-"), so both the main and ElasticsearchToMigrate options get it, and compute the EnableSnapshotJobs default after parsing, since it depends on ScopePrefix. In DataMigrationJob, use ElasticsearchToMigrate.ScopePrefix so both sides use the same - separator. If per-connection scoping isn't wanted, remove the scope parsing for the main connection string and keep it only for ElasticsearchToMigrate.

Activity

  1. ejsmith commented on Nov 4, 2026

    @ejsmith
    MemberAuthor

    Closing. AppScope is the supported way to prefix index names. The scope key in the connection string is only used for ElasticsearchToMigrate, so on the main cluster it does nothing and causes no harm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions