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.
- #create_river(type, create_options, options = {}) ⇒ Object
- #delete_index(index, options = {}) ⇒ Object
- #delete_mapping(options = {}) ⇒ Object
- #delete_river(type = nil, options = {}) ⇒ Object
-
#flush(*args) ⇒ Object
list of indices, or :all options: refresh default: default_index if defined, otherwise :all.
- #get_aliases(index = default_index, options = {}) ⇒ Object
- #get_river(type, options = {}) ⇒ Object
- #get_settings(index = default_index, options = {}) ⇒ Object
- #index_mapping(*args) ⇒ Object
- #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.
- #river_status(type, options = {}) ⇒ Object
-
#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.
- #update_settings(settings, options = {}) ⇒ Object
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”}]
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/elasticsearch/client/admin_index.rb', line 40 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
22 23 24 25 26 27 |
# File 'lib/elasticsearch/client/admin_index.rb', line 22 def create_index(index, ={}, ={}) unless [:index] = { :index => } end execute(:create_index, index, , ) end |
#create_river(type, create_options, options = {}) ⇒ Object
131 132 133 |
# File 'lib/elasticsearch/client/admin_index.rb', line 131 def create_river(type, , ={}) execute(:create_river, type, , ) end |
#delete_index(index, options = {}) ⇒ Object
29 30 31 |
# File 'lib/elasticsearch/client/admin_index.rb', line 29 def delete_index(index, ={}) execute(:delete_index, index, ) end |
#delete_mapping(options = {}) ⇒ Object
77 78 79 80 |
# File 'lib/elasticsearch/client/admin_index.rb', line 77 def delete_mapping(={}) index, type, = extract_required_scope() execute(:delete_mapping, index, type, ) end |
#delete_river(type = nil, options = {}) ⇒ Object
143 144 145 |
# File 'lib/elasticsearch/client/admin_index.rb', line 143 def delete_river(type=nil, ={}) execute(:delete_river, type, ) end |
#flush(*args) ⇒ Object
list of indices, or :all options: refresh default: default_index if defined, otherwise :all
94 95 96 97 98 99 |
# File 'lib/elasticsearch/client/admin_index.rb', line 94 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 |
#get_aliases(index = default_index, options = {}) ⇒ Object
58 59 60 61 |
# File 'lib/elasticsearch/client/admin_index.rb', line 58 def get_aliases(index=default_index, ={}) index, type, = extract_scope() execute(:get_aliases, index, ) end |
#get_river(type, options = {}) ⇒ Object
135 136 137 |
# File 'lib/elasticsearch/client/admin_index.rb', line 135 def get_river(type, ={}) execute(:get_river, type, ) end |
#get_settings(index = default_index, options = {}) ⇒ Object
87 88 89 |
# File 'lib/elasticsearch/client/admin_index.rb', line 87 def get_settings(index=default_index, ={}) execute(:get_settings, index, ) end |
#index_mapping(*args) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/elasticsearch/client/admin_index.rb', line 14 def index_mapping(*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_mapping, 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
124 125 126 127 128 129 |
# File 'lib/elasticsearch/client/admin_index.rb', line 124 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
104 105 106 107 108 109 |
# File 'lib/elasticsearch/client/admin_index.rb', line 104 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 |
#river_status(type, options = {}) ⇒ Object
139 140 141 |
# File 'lib/elasticsearch/client/admin_index.rb', line 139 def river_status(type, ={}) execute(:river_status, type, ) end |
#snapshot(*args) ⇒ Object
list of indices, or :all no options default: default_index if defined, otherwise all
114 115 116 117 118 119 |
# File 'lib/elasticsearch/client/admin_index.rb', line 114 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
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/elasticsearch/client/admin_index.rb', line 64 def update_mapping(mapping, ={}) index, type, = extract_required_scope() = .dup indices = Array(index) unless mapping[type] mapping = { type => mapping } end indices.collect! { |i| PSEUDO_INDICES.include?(i) ? "_#{i}" : i } execute(:update_mapping, indices, type, mapping, ) end |
#update_settings(settings, options = {}) ⇒ Object
82 83 84 85 |
# File 'lib/elasticsearch/client/admin_index.rb', line 82 def update_settings(settings, ={}) index, type, = extract_scope() execute(:update_settings, index, settings, ) end |