Skip to content

Commit 8730777

Browse files
committed
[API] Added, that indices.delete accepts the :ignore parameter
1 parent ad20d4a commit 8730777

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

elasticsearch-api/lib/elasticsearch/api/actions/indices/delete.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ def delete(arguments={})
3939
body = nil
4040

4141
perform_request(method, path, params, body).body
42+
43+
rescue Exception => e
44+
# NOTE: Use exception name, not full class in Elasticsearch::Client to allow client plugability
45+
if Array(arguments[:ignore]).include?(404) && e.class.to_s =~ /NotFound/; false
46+
else raise(e)
47+
end
4248
end
4349
end
4450
end

elasticsearch-api/test/unit/indices/delete_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ class IndicesDeleteTest < ::Test::Unit::TestCase
4747
subject.indices.delete :index => 'foo^bar'
4848
end
4949

50+
should "catch a NotFound exception with the ignore parameter" do
51+
subject.expects(:perform_request).raises(NotFound)
52+
53+
assert_nothing_raised do
54+
subject.indices.delete :index => 'foo', :ignore => 404
55+
end
56+
end
5057
end
5158

5259
end

0 commit comments

Comments
 (0)