Class: Chewy::Index::Settings
Overview
Stores ElasticSearch index settings and resolves ‘analysis` hash. At first, you need to store some analyzers or other analysis options to the corresponding repository:
Chewy.analyzer :title_analyzer, type: 'custom', filter: %w(lowercase icu_folding title_nysiis)
Chewy.filter :title_nysiis, type: 'phonetic', encoder: 'nysiis', replace: false
‘title_nysiis` filter here will be expanded automatically when `title_analyzer` analyser will be used in index settings:
class ProductsIndex < Chewy::Index
settings analysis: {
analyzer: [
'title_analyzer',
{one_more_analyzer: {type: 'custom', tokenizer: 'lowercase'}}
]
}
end
Additional analysing options, which wasn’t stored in repositories, might be used as well.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Settings
constructor
A new instance of Settings.
- #to_hash ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Settings
Returns a new instance of Settings.
27 28 29 |
# File 'lib/chewy/index/settings.rb', line 27 def initialize(params = {}) @params = params end |
Instance Method Details
#to_hash ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/chewy/index/settings.rb', line 31 def to_hash settings = @params.deep_symbolize_keys settings[:analysis] = resolve_analysis(settings[:analysis]) if settings[:analysis] if settings[:index] || Chewy.configuration[:index] settings[:index] = (Chewy.configuration[:index] || {}) .deep_merge((settings[:index] || {}).deep_symbolize_keys) end settings.present? ? {settings: settings} : {} end |