Feature Proposal: declare index aliases in the schema definition API #1364
Replies: 3 comments 1 reply
|
An alternative is to have this alias set in environment-specific YAML. But I think this interface is simpler, and I don't see a need for it to be env-specific yet. |
|
Thanks for the thorough writeup, @markyang-toast. One nuance to flag: aliases on existing concrete indices are never clobbered ( Taking a step backElasticGraph itself does nothing with aliases — it never writes through them (the indexer computes concrete rollover index names) and never queries through them. A dedicated Your use case — clients querying OpenSearch directly — isn't really about aliases specifically; it's "configure the datastore in ways EG doesn't model." Aliases are one instance; field aliases, ISM policies, and future ES/OS features are others. I'd rather solve that class of need once, with a general-purpose customization hook. This also keeps the door open for a first-class Proposal:
|
Uh oh!
There was an error while loading. Please reload this page.
Summary
ElasticGraph generates an
aliaseskey intodatastore_config.yamlfor both indices and indextemplates, but always leaves it empty, and there's no schema definition API for it. Proposing one:
Use cases are the usual ones: a stable name across a reindex cutover, a single queryable name in front
of rollover indices for consumers that read the index directly rather than through GraphQL, and
filtered aliases for coarse read scoping.
The problem
Indexing::Indexhardcodes"aliases" => {}in both emit paths:Because it's emitted rather than omitted, an alias created outside ElasticGraph doesn't survive:
ForIndexTemplate#put_index_templatePUTs the whole template, so a template alias isremoved on the next mapping or settings change.
ForIndex#create_new_indexpassesaliases: {}, so newly created indicesnever get aliases — including rollover indices, since
ForIndexTemplateconfigures those throughForIndexusing the template config.configure!reconciles settings and mappings only. Aliases are neverinspected, so a missing one is never repaired.
So alias state can't be expressed in the schema, can't be recreated on a clean cluster, and silently
regresses after a routine
clusters:configure.Proposal
1.
i.alias <name>, optionally withfilter:, populating thealiaseskey in bothto_index_configandto_index_template_config. BecauseForIndexTemplatepasses the template configdown to
ForIndexfor related rollover indices, one declaration covers the template, indices createdby admin, and indices auto-created by the datastore from the template.
2. Reconcile aliases on indices that already exist, via
_aliasesinForIndex#configure!—currently the only surface with no path to pick up a newly declared alias.
3. Absent means "leave alone", not "remove all."
elasticgraph-adminadds and updates declaredaliases and never removes one it didn't declare. This also fixes the clobbering above regardless of
whether anyone adopts the new API, so it may be worth landing on its own first.
Low blast radius: ElasticGraph never writes through an alias — the indexer computes concrete rollover
index names, and
related_rollover_indicesusescat indices, which doesn't return aliases. Read pathonly, so
is_write_indexnever comes up.All reactions