Module: ElasticSearch::Api::Admin::Index
- Included in:
- Client
- Defined in:
- lib/elasticsearch/client/admin_index.rb
Constant Summary collapse
- PSEUDO_INDICES =
[:all]
Instance Method Summary collapse
-
#alias_index(operations, options = {}) ⇒ Object
:add => { “index” => “alias” } :add => [=> “alias”, => “alias2”] :add => { “index” => “alias”, “index2” => “alias2” } :remove => { “index” => “alias” } :remove => [=> “alias”, {“index2” => “alias2”] :remove => { “index” => “alias”, “index2” => “alias2” } :actions => [=> {:index => “index”, :alias => “alias”}].
-
#create_index(index, create_options = {}, options = {}) ⇒ Object
options: number_of_shards, number_of_replicas.
- #delete_index(index, options = {}) ⇒ Object
-
#flush(*args) ⇒ Object
list of indices, or :all options: refresh default: default_index if defined, otherwise :all.
- #index_status(*args) ⇒ Object
-
#optimize(*args) ⇒ Object
list of indices, or :all options: max_num_segments, only_expunge_deletes, refresh, flush default: default_index if defined, otherwise all.
-
#refresh(*args) ⇒ Object
list of indices, or :all no options default: default_index if defined, otherwise all.
-
#snapshot(*args) ⇒ Object
list of indices, or :all no options default: default_index if defined, otherwise all.
-
#update_mapping(mapping, options = {}) ⇒ Object
options: ignore_conflicts.
Instance Method Details
#alias_index(operations, options = {}) ⇒ Object
:add => { “index” => “alias” } :add => [=> “alias”, => “alias2”] :add => { “index” => “alias”, “index2” => “alias2” } :remove => { “index” => “alias” } :remove => [=> “alias”, {“index2” => “alias2”] :remove => { “index” => “alias”, “index2” => “alias2” } :actions => [=> {:index => “index”, :alias => “alias”}]
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/elasticsearch/client/admin_index.rb', line 33 def alias_index(operations, ={}) if operations[:actions] alias_ops = operations else alias_ops = { :actions => [] } [:add, :remove].each do |op| next unless operations.has_key?(op) op_actions = operations[op].is_a?(Array) ? operations[op] : [operations[op]] op_actions.each do |action_hash| action_hash.each do |index, index_alias| alias_ops[:actions] << { op => { :index => index, :alias => index_alias }} end end end end execute(:alias_index, alias_ops, ) end |
#create_index(index, create_options = {}, options = {}) ⇒ Object
options: number_of_shards, number_of_replicas
15 16 17 18 19 20 |
# File 'lib/elasticsearch/client/admin_index.rb', line 15 def create_index(index, ={}, ={}) unless [:index] = { :index => } end execute(:create_index, index, , ) end |
#delete_index(index, options = {}) ⇒ Object
22 23 24 |
# File 'lib/elasticsearch/client/admin_index.rb', line 22 def delete_index(index, ={}) execute(:delete_index, index, ) end |
#flush(*args) ⇒ Object
list of indices, or :all options: refresh default: default_index if defined, otherwise :all
70 71 72 73 74 75 |
# File 'lib/elasticsearch/client/admin_index.rb', line 70 def flush(*args) = args.last.is_a?(Hash) ? args.pop : {} indices = args.empty? ? [(default_index || :all)] : args.flatten indices.collect! { |i| PSEUDO_INDICES.include?(i) ? "_#{i}" : i } execute(:flush, indices, ) end |
#index_status(*args) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/elasticsearch/client/admin_index.rb', line 7 def index_status(*args) = args.last.is_a?(Hash) ? args.pop : {} indices = args.empty? ? [(default_index || :all)] : args.flatten indices.collect! { |i| PSEUDO_INDICES.include?(i) ? "_#{i}" : i } execute(:index_status, indices, ) end |
#optimize(*args) ⇒ Object
list of indices, or :all options: max_num_segments, only_expunge_deletes, refresh, flush default: default_index if defined, otherwise all
100 101 102 103 104 105 |
# File 'lib/elasticsearch/client/admin_index.rb', line 100 def optimize(*args) = args.last.is_a?(Hash) ? args.pop : {} indices = args.empty? ? [(default_index || :all)] : args.flatten indices.collect! { |i| PSEUDO_INDICES.include?(i) ? "_#{i}" : i } execute(:optimize, indices, ) end |
#refresh(*args) ⇒ Object
list of indices, or :all no options default: default_index if defined, otherwise all
80 81 82 83 84 85 |
# File 'lib/elasticsearch/client/admin_index.rb', line 80 def refresh(*args) = args.last.is_a?(Hash) ? args.pop : {} indices = args.empty? ? [(default_index || :all)] : args.flatten indices.collect! { |i| PSEUDO_INDICES.include?(i) ? "_#{i}" : i } execute(:refresh, indices, ) end |
#snapshot(*args) ⇒ Object
list of indices, or :all no options default: default_index if defined, otherwise all
90 91 92 93 94 95 |
# File 'lib/elasticsearch/client/admin_index.rb', line 90 def snapshot(*args) = args.last.is_a?(Hash) ? args.pop : {} indices = args.empty? ? [(default_index || :all)] : args.flatten indices.collect! { |i| PSEUDO_INDICES.include?(i) ? "_#{i}" : i } execute(:snapshot, indices, ) end |
#update_mapping(mapping, options = {}) ⇒ Object
options: ignore_conflicts
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/elasticsearch/client/admin_index.rb', line 52 def update_mapping(mapping, ={}) set_default_scope!() raise "index and type or defaults required" unless [:index] && [:type] = .dup indices = Array(.delete(:index)) type = .delete(:type) unless mapping[type] mapping = { type => mapping } end indices.collect! { |i| PSEUDO_INDICES.include?(i) ? "_#{i}" : i } execute(:update_mapping, indices, type, mapping, ) end |