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

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”}]



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/elasticsearch/client/admin_index.rb', line 36

def alias_index(operations, options={})
  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, options)
end

#create_index(index, create_options = {}, options = {}) ⇒ Object

options: number_of_shards, number_of_replicas



18
19
20
21
22
23
# File 'lib/elasticsearch/client/admin_index.rb', line 18

def create_index(index, create_options={}, options={})
  unless create_options[:index]
    create_options = { :index => create_options }
  end
  execute(:create_index, index, create_options, options)
end

#create_river(type, create_options, options = {}) ⇒ Object



119
120
121
# File 'lib/elasticsearch/client/admin_index.rb', line 119

def create_river(type, create_options, options={})
  execute(:create_river, type, create_options, options)
end

#delete_index(index, options = {}) ⇒ Object



25
26
27
# File 'lib/elasticsearch/client/admin_index.rb', line 25

def delete_index(index, options={})
  execute(:delete_index, index, options)
end

#delete_mapping(options = {}) ⇒ Object



73
74
75
76
# File 'lib/elasticsearch/client/admin_index.rb', line 73

def delete_mapping(options={})
  index, type, options = extract_required_scope(options)
  execute(:delete_mapping, index, type, options)
end

#delete_river(type = nil, options = {}) ⇒ Object



131
132
133
# File 'lib/elasticsearch/client/admin_index.rb', line 131

def delete_river(type=nil, options={})
  execute(:delete_river, type, options)
end

#flush(*args) ⇒ Object

list of indices, or :all options: refresh default: default_index if defined, otherwise :all



90
91
92
93
# File 'lib/elasticsearch/client/admin_index.rb', line 90

def flush(*args)
  indices, options = extract_indices_and_options(args)
  execute(:flush, indices, options)
end

#get_aliases(index = nil, options = {}) ⇒ Object



54
55
56
57
# File 'lib/elasticsearch/client/admin_index.rb', line 54

def get_aliases(index=nil, options={})
  scope_index, type, options = extract_scope(options)
  execute(:get_aliases, index || scope_index, options)
end

#get_river(type, options = {}) ⇒ Object



123
124
125
# File 'lib/elasticsearch/client/admin_index.rb', line 123

def get_river(type, options={})
  execute(:get_river, type, options)
end

#get_settings(index = default_index, options = {}) ⇒ Object



83
84
85
# File 'lib/elasticsearch/client/admin_index.rb', line 83

def get_settings(index=default_index, options={})
  execute(:get_settings, index, options)
end

#index_mapping(*args) ⇒ Object



12
13
14
15
# File 'lib/elasticsearch/client/admin_index.rb', line 12

def index_mapping(*args)
  indices, options = extract_indices_and_options(args)
  execute(:index_mapping, indices, options)
end

#index_status(*args) ⇒ Object



7
8
9
10
# File 'lib/elasticsearch/client/admin_index.rb', line 7

def index_status(*args)
  indices, options = extract_indices_and_options(args)
  execute(:index_status, indices, options)
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



114
115
116
117
# File 'lib/elasticsearch/client/admin_index.rb', line 114

def optimize(*args)
  indices, options = extract_indices_and_options(args)
  execute(:optimize, indices, options)
end

#refresh(*args) ⇒ Object

list of indices, or :all no options default: default_index if defined, otherwise all



98
99
100
101
# File 'lib/elasticsearch/client/admin_index.rb', line 98

def refresh(*args)
  indices, options = extract_indices_and_options(args)
  execute(:refresh, indices, options)
end

#river_status(type, options = {}) ⇒ Object



127
128
129
# File 'lib/elasticsearch/client/admin_index.rb', line 127

def river_status(type, options={})
  execute(:river_status, type, options)
end

#snapshot(*args) ⇒ Object

list of indices, or :all no options default: default_index if defined, otherwise all



106
107
108
109
# File 'lib/elasticsearch/client/admin_index.rb', line 106

def snapshot(*args)
  indices, options = extract_indices_and_options(args)
  execute(:snapshot, indices, options)
end

#update_mapping(mapping, options = {}) ⇒ Object

options: ignore_conflicts



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/elasticsearch/client/admin_index.rb', line 60

def update_mapping(mapping, options={})
  index, type, options = extract_required_scope(options)

  options = options.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, options)
end

#update_settings(settings, options = {}) ⇒ Object



78
79
80
81
# File 'lib/elasticsearch/client/admin_index.rb', line 78

def update_settings(settings, options={})
  index, type, options = extract_scope(options)
  execute(:update_settings, index, settings, options)
end