Class: EsMigration
Instance Method Summary
collapse
#operation_list, template
#alias_index_op, #create_index_op, #delete_index_op, #update_mapping_op, #update_settings_op
define, perform
#getset, #getset_collection_item
Instance Method Details
#combined_operations ⇒ Object
136
137
138
|
# File 'lib/wukong-migrate/elasticsearch_migration.rb', line 136
def combined_operations
operation_list + nested_operations
end
|
#nested_operations ⇒ Object
132
133
134
|
# File 'lib/wukong-migrate/elasticsearch_migration.rb', line 132
def nested_operations
(creations.to_a + updates.to_a).map{ |idx| idx.operation_list }.flatten
end
|
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
# File 'lib/wukong-migrate/elasticsearch_migration.rb', line 140
def perform(options = {})
combined_operations.each do |op|
op.configure_with options
log.info op.info
log.debug op.raw_curl_string
response = op.execute
log.debug [response.code, response.parsed_response].join(' ')
if response.code == 200
log.info 'Operation complete'
else
log.error response.parsed_response
break unless options[:force]
end
end
end
|
#receive_create_index(attrs, &block) ⇒ Object
114
115
116
117
118
|
# File 'lib/wukong-migrate/elasticsearch_migration.rb', line 114
def receive_create_index(attrs, &block)
idx = IndexDsl.receive(attrs, &block)
operation_list << create_index_op(idx.name, idx.index_settings)
idx
end
|
#receive_delete_index(attrs, &block) ⇒ Object
126
127
128
129
130
|
# File 'lib/wukong-migrate/elasticsearch_migration.rb', line 126
def receive_delete_index(attrs, &block)
idx = IndexDsl.receive(attrs, &block)
operation_list.unshift delete_index_op(idx.name)
idx
end
|
#receive_update_index(attrs, &block) ⇒ Object
120
121
122
123
124
|
# File 'lib/wukong-migrate/elasticsearch_migration.rb', line 120
def receive_update_index(attrs, &block)
idx = IndexDsl.receive(attrs, &block)
operation_list << update_settings_op(idx.name, idx.index_settings)
idx
end
|