Skip to content
This repository has been archived by the owner on Jun 30, 2018. It is now read-only.

Fixing settings failure problem where there is no index #816

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/tire/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def delete_mapping(type)

def settings
@response = Configuration.client.get("#{url}/_settings")
MultiJson.decode(@response.body)[@name]['settings']
MultiJson.decode(@response.body).fetch(@name, {}).fetch('settings', {})
end

def store(*args)
Expand Down
11 changes: 10 additions & 1 deletion test/unit/index_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,16 @@ class IndexTest < Test::Unit::TestCase

assert_equal '20', @index.settings['index.number_of_shards']
end


should "return a blank hash for settings if the index is missing" do
json = <<-JSON
{"error":"IndexMissingException[[foo] missing]","status":404}
JSON

Configuration.client.stubs(:get).returns(mock_response(json, 404))

assert_equal ({}), Tire.index('foo').settings
end
end

context "when storing" do
Expand Down