Skip to content

Commit

Permalink
Merge pull request #14 from Sage/fix_settings_method
Browse files Browse the repository at this point in the history
Fixes a bug with the settings method when passed multiple times
  • Loading branch information
chrisbarber86 authored Jun 6, 2018
2 parents d19329f + c2527ed commit ad3ba92
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v2.0.1
The settings method when passed multiple times it was replacing the key value instead of building a hash of data within the name / type keys.

## v2.0.0
### Breaking change

Expand Down
8 changes: 3 additions & 5 deletions lib/elastic_search_framework/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ def delete

def settings(name:, type: nil, value:)
self.index_settings = {} if index_settings.nil?
index_settings[name] = if type
{ type => value }
else
value
end
index_settings[name] = {} if index_settings[name].nil?
return index_settings[name][type] = value if type
index_settings[name] = value
end

def create_payload
Expand Down
2 changes: 1 addition & 1 deletion lib/elastic_search_framework/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ElasticSearchFramework
VERSION = '2.0.0'
VERSION = '2.0.1'
end
9 changes: 8 additions & 1 deletion spec/elastic_search_framework/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@
'filter' => ['lowercase'],
'type' => 'custom'
}
}
},
'analyzer'=>{
'custom_analyzer'=>{
'filter'=>['lowercase'],
'type'=>'custom',
'tokenizer'=>'standard'
}
}
}
end

Expand Down
2 changes: 2 additions & 0 deletions spec/example_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ class ExampleIndexWithSettings
index name: 'example_index'

normalizer_value = { custom_normalizer: { type: 'custom', char_filter: [], filter: ['lowercase'] } }
analyzer_value = { custom_analyzer: { type: 'custom', tokenizer: 'standard', filter: %w(lowercase) } }

settings name: :number_of_shards, value: 1
settings name: :analysis, type: :normalizer, value: normalizer_value
settings name: :analysis, type: :analyzer, value: analyzer_value
mapping name: 'default', field: :name, type: :keyword, index: true
end

Expand Down

0 comments on commit ad3ba92

Please sign in to comment.