Title / Description
Code def update_dynamic_templates(model) index = model.table_name doc_type = ElasticSearch::GlobalSearch::Sync.els_type_for_class(model) body = { doc_type => { dynamic_templates: ElasticSearch::GlobalSearch::Indexes::DYNAMIC_TEMPLATES } } result = ElasticSearch::GlobalSearch::Config.client.indices.put_mapping index: index, type: doc_type, body: body if result["acknowledged"] puts "#{index} - Done" if ElasticSearch::GlobalSearch::Config::INDEX_TO_PERCOLATE.include?(index.to_sym) perc_result = ElasticSearch::GlobalSearch::Config.client.indices.put_mapping index: ElasticSearch::Percolator.index_percolator(index), type: doc_type, body: body if perc_result["acknowledged"] puts "#{index} percolator - Done" else puts "#{index} percolator - Failed, error: #{result}" end end else puts "#{index} - Failed, error: #{result}" end end def update_all_dynamic_templates ElasticSearch::GlobalSearch::Config.each_synced_model do |model| update_dynamic_templates(model) end end
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code