Class: Esse::CLI::Index
- Inherits:
-
Base
- Object
- Thor
- Base
- Esse::CLI::Index
show all
- Defined in:
- lib/esse/cli/index.rb
Defined Under Namespace
Classes: BaseOperation, Close, Create, Delete, Import, Open, Reset, UpdateAliases, UpdateLazyAttributes, UpdateMapping, UpdateSettings
Instance Method Summary
collapse
Instance Method Details
#close(*index_classes) ⇒ Object
106
107
108
109
|
# File 'lib/esse/cli/index.rb', line 106
def close(*index_classes)
require_relative 'index/close'
Close.new(indices: index_classes, **options.to_h.transform_keys(&:to_sym)).run
end
|
#create(*index_classes) ⇒ Object
63
64
65
66
67
|
# File 'lib/esse/cli/index.rb', line 63
def create(*index_classes)
require_relative 'index/create'
opts = HashUtils.deep_transform_keys(options.to_h, &:to_sym)
Create.new(indices: index_classes, **opts).run
end
|
#delete(*index_classes) ⇒ Object
71
72
73
74
|
# File 'lib/esse/cli/index.rb', line 71
def delete(*index_classes)
require_relative 'index/delete'
Delete.new(indices: index_classes, **options.to_h.transform_keys(&:to_sym)).run
end
|
#import(*index_classes) ⇒ Object
125
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/esse/cli/index.rb', line 125
def import(*index_classes)
require_relative 'index/import'
opts = HashUtils.deep_transform_keys(options.to_h, &:to_sym)
%i[preload_lazy_attributes eager_load_lazy_attributes update_lazy_attributes].each do |key|
if (val = opts.delete(key)) && val != 'false'
val = 'true' if val == key.to_s
opts[key] = (val == 'true') ? true : val.split(',')
end
end
Import.new(indices: index_classes, **opts).run
end
|
#open(*index_classes) ⇒ Object
113
114
115
116
|
# File 'lib/esse/cli/index.rb', line 113
def open(*index_classes)
require_relative 'index/open'
Open.new(indices: index_classes, **options.to_h.transform_keys(&:to_sym)).run
end
|
#reset(*index_classes) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/esse/cli/index.rb', line 26
def reset(*index_classes)
require_relative 'index/reset'
opts = HashUtils.deep_transform_keys(options.to_h, &:to_sym)
opts[:reindex] = Parser::BoolOrHash.new(:reindex, default: false).parse(opts[:reindex])
opts[:import] = Parser::BoolOrHash.new(:import, default: true).parse(opts[:import])
if opts[:import] && opts[:reindex]
raise ArgumentError, 'You cannot use --import and --reindex together'
end
%i[preload_lazy_attributes eager_load_lazy_attributes update_lazy_attributes].each do |key|
val = opts.delete(key)
val = 'true' if val == key.to_s
next if val.nil? || val == 'false'
if opts[:reindex]
raise ArgumentError, "You cannot use --#{key}=#{val} with --reindex"
elsif opts[:import] == false
raise ArgumentError, "You cannot use --#{key}=#{val} with --import=false"
end
opts[:import] = {} if opts[:import] == true
opts[:import][key] = (val == 'true') ? true : val.split(',')
end
Reset.new(indices: index_classes, **opts).run
end
|
#update_aliases(*index_classes) ⇒ Object
78
79
80
81
82
83
84
|
# File 'lib/esse/cli/index.rb', line 78
def update_aliases(*index_classes)
require_relative 'index/update_aliases'
kwargs = options.to_h.transform_keys(&:to_sym)
kwargs[:suffix] = (kwargs[:suffix] || []).flat_map { |s| s.split(',') }.uniq
UpdateAliases.new(indices: index_classes, **kwargs).run
end
|
#update_lazy_attributes(index_class, *attributes) ⇒ Object
142
143
144
145
146
|
# File 'lib/esse/cli/index.rb', line 142
def update_lazy_attributes(index_class, *attributes)
require_relative "index/update_lazy_attributes"
opts = HashUtils.deep_transform_keys(options.to_h, &:to_sym)
UpdateLazyAttributes.new(indices: [index_class], attributes: attributes, **opts).run
end
|
#update_mapping(*index_classes) ⇒ Object
99
100
101
102
|
# File 'lib/esse/cli/index.rb', line 99
def update_mapping(*index_classes)
require_relative 'index/update_mapping'
UpdateMapping.new(indices: index_classes, **options.to_h.transform_keys(&:to_sym)).run
end
|
#update_settings(*index_classes) ⇒ Object
90
91
92
93
94
|
# File 'lib/esse/cli/index.rb', line 90
def update_settings(*index_classes)
require_relative 'index/update_settings'
opts = HashUtils.deep_transform_keys(options.to_h, &:to_sym)
UpdateSettings.new(indices: index_classes, **opts).run
end
|