Module: Elastic::Railties::Utils
- Included in:
- Elastic
- Defined in:
- lib/elastic/railties/utils.rb
Instance Method Summary collapse
- #cleanup ⇒ Object
- #drop(_index = nil) ⇒ Object
- #migrate(_index = nil) ⇒ Object
- #reindex(_index = nil) ⇒ Object
- #remap(_index = nil) ⇒ Object
- #stats(_index = nil) ⇒ Object
Instance Method Details
#cleanup ⇒ Object
31 32 33 34 |
# File 'lib/elastic/railties/utils.rb', line 31 def cleanup logger.info "Searching for orphan indices" indices.each { |index| index.connector.remove_orphaned_indices } end |
#drop(_index = nil) ⇒ Object
36 37 38 39 |
# File 'lib/elastic/railties/utils.rb', line 36 def drop(_index = nil) logger.info "Dropping all indices" if _index.nil? indices(_index).each &:drop end |
#migrate(_index = nil) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/elastic/railties/utils.rb', line 23 def migrate(_index = nil) logger.info "Migrating all indices" if _index.nil? indices(_index).each do |index| logger.info "Migrating index #{index.suffix}" handle_errors { index.migrate } end end |
#reindex(_index = nil) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/elastic/railties/utils.rb', line 3 def reindex(_index = nil) logger.info "Reindexing all indices" if _index.nil? indices(_index).each do |index| logger.info "Reindexing index #{index.suffix}" handle_errors { index.reindex } end end |
#remap(_index = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/elastic/railties/utils.rb', line 11 def remap(_index = nil) logger.info "Remapping all indices" if _index.nil? indices(_index).each do |index| logger.info "Remapping index #{index.suffix}" handle_errors do unless index.connector.remap logger.info 'Mapping couldnt be changed, make sure you call migrate' end end end end |
#stats(_index = nil) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/elastic/railties/utils.rb', line 41 def stats(_index = nil) logger.info "Indices stats" if _index.nil? indices(_index).each do |index| logger.info "Stats for #{index.suffix}:" # TODO. end end |