-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: master
Are you sure you want to change the base?
Changes from all commits
d7f0fd2
b3a972e
48f8b4c
2b31c2c
c02ca65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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'] | ||||||
| end | ||||||
|
|
||||||
| end | ||||||
|
|
||||||
| def exists? | ||||||
|
|
@@ -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 } | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| rescue Elasticsearch::Transport::Transport::Errors::NotFound | ||||||
| nil | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, much better |
||||||
| end | ||||||
|
|
||||||
| def get_first_parent_index_reference | ||||||
| index_name = parent_index_names&.first | ||||||
| return nil if index_name.nil? | ||||||
| self.class.new(@index_name, force_name: index_name) | ||||||
| end | ||||||
|
|
||||||
| def config | ||||||
| ::Waistband.config.index @index_name | ||||||
| end | ||||||
|
|
@@ -345,7 +361,7 @@ def full_alias_name(alias_name) | |||||
| end | ||||||
|
|
||||||
| def custom_name? | ||||||
| !!config['name'] | ||||||
| !!config['name'] || !!(defined? @force_name) | ||||||
| end | ||||||
|
|
||||||
| def stringify_all(data) | ||||||
|
|
@@ -381,6 +397,7 @@ def settings | |||||
| end | ||||||
|
|
||||||
| def config_name | ||||||
| return @force_name if defined? @force_name | ||||||
| @subs ? "#{base_config_name}__#{@subs.join('_')}" : base_config_name | ||||||
| end | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
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_nameversusalias_name?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.