Skip to content

Commit

Permalink
Exit with an error in the Rake import task when the index as not crea…
Browse files Browse the repository at this point in the history
…ted in elasticsearch

Previously, when the index could not be created due to eg. error in mapping,
it was silently ignored and data were still indexed (with dynamic mapping).

This was a source of hard-to-pin-down errors. When there's an error while
creating the index, the Rake task will exit(1) and print the HTTP response, now.

Closes karmi#392
  • Loading branch information
karmi committed Oct 19, 2012
1 parent 840fdcd commit 65cd994
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/tire/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ def elapsed_to_human(elapsed)
unless index.exists?
mapping = MultiJson.encode(klass.tire.mapping_to_hash, :pretty => Tire::Configuration.pretty)
puts "[IMPORT] Creating index '#{index.name}' with mapping:", mapping
index.create :mappings => klass.tire.mapping_to_hash, :settings => klass.tire.settings
unless index.create( :mappings => klass.tire.mapping_to_hash, :settings => klass.tire.settings )
STDERR.puts "[ERROR] There has been an error when creating the index -- elasticsearch returned:",
index.response
exit(1)
end
end

STDOUT.sync = true
Expand Down

0 comments on commit 65cd994

Please sign in to comment.