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', {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 = {}, &block) ⇒ Settings
constructor
A new instance of Settings.
- #to_hash ⇒ Object
Constructor Details
#initialize(params = {}, &block) ⇒ Settings
Returns a new instance of Settings.
26 27 28 29 |
# File 'lib/chewy/index/settings.rb', line 26 def initialize(params = {}, &block) @params = params @proc_params = block end |
Instance Method Details
#to_hash ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/chewy/index/settings.rb', line 31 def to_hash settings = @params.deep_symbolize_keys settings.merge!((@proc_params.call || {}).deep_symbolize_keys) if @proc_params 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 |