Skip to content

Alias and force name #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

bsampietro
Copy link

To be able to migrate indexes with no downtime we need to be able to use aliases and to create indexes with custom names on ES. This PR adds the possibility of using custom names (outside of config) and adds methods to be able to get to the index reference (for creation and deletion) if using an alias.

@@ -261,6 +265,18 @@ def alias_exists?(alias_name)
)
end

def parent_index_names
client.indices.get_alias(name: config_name).map { |k, v| k }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
client.indices.get_alias(name: config_name).map { |k, v| k }
client.indices.get_alias(name: config_name).keys

def parent_index_names
client.indices.get_alias(name: config_name).map { |k, v| k }
rescue Elasticsearch::Transport::Transport::Errors::NotFound
nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather return an empty array here and keep the return type consistent.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, much better

@@ -29,6 +29,10 @@ def initialize(index_name, options = {})
@subs = @subs.flatten if @subs.is_a?(Array)
end

if options['force_name'].present?
@force_name = options['force_name']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to call this force_name versus alias_name?

Copy link
Author

@bsampietro bsampietro Jan 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because an index name could also be used. It is an overwriting from the name on the config file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants