Class: Esse::CLI::Index

Inherits:
Base
  • Object
show all
Defined in:
lib/esse/cli/index.rb

Defined Under Namespace

Classes: BaseOperation, Close, Create, Delete, Import, Open, Reset, UpdateAliases, UpdateMapping, UpdateSettings

Instance Method Summary collapse

Instance Method Details

#close(*index_classes) ⇒ Object



84
85
86
87
# File 'lib/esse/cli/index.rb', line 84

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



41
42
43
44
45
# File 'lib/esse/cli/index.rb', line 41

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



49
50
51
52
# File 'lib/esse/cli/index.rb', line 49

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



102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/esse/cli/index.rb', line 102

def import(*index_classes)
  require_relative 'index/import'
  opts = HashUtils.deep_transform_keys(options.to_h, &:to_sym)
  opts.delete(:lazy_update_document_attributes) if opts[:lazy_update_document_attributes] == 'false'
  opts.delete(:eager_include_document_attributes) if opts[:eager_include_document_attributes] == 'false'
  if (val = opts[:eager_include_document_attributes])
    opts[:eager_include_document_attributes] = (val == 'true') ? true : val.split(',')
  end
  if (val = opts[:lazy_update_document_attributes])
    opts[:lazy_update_document_attributes] = (val == 'true') ? true : val.split(',')
  end
  Import.new(indices: index_classes, **opts).run
end

#open(*index_classes) ⇒ Object



91
92
93
94
# File 'lib/esse/cli/index.rb', line 91

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



22
23
24
25
26
27
28
29
# File 'lib/esse/cli/index.rb', line 22

def reset(*index_classes)
  require_relative 'index/reset'
  opts = HashUtils.deep_transform_keys(options.to_h, &:to_sym)
  if opts[:import] && opts[:reindex]
    raise ArgumentError, 'You cannot use --import and --reindex together'
  end
  Reset.new(indices: index_classes, **opts).run
end

#update_aliases(*index_classes) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/esse/cli/index.rb', line 56

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_mapping(*index_classes) ⇒ Object



77
78
79
80
# File 'lib/esse/cli/index.rb', line 77

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



68
69
70
71
72
# File 'lib/esse/cli/index.rb', line 68

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