1
0

index_extensions.rb 523 B

123456789101112131415161718
  1. # frozen_string_literal: true
  2. module Chewy
  3. module IndexExtensions
  4. def index_preset(base_options = {})
  5. case ENV['ES_PRESET'].presence
  6. when 'single_node_cluster', nil
  7. base_options.merge(number_of_replicas: 0)
  8. when 'small_cluster'
  9. base_options.merge(number_of_replicas: 1)
  10. when 'large_cluster'
  11. base_options.merge(number_of_replicas: 1, number_of_shards: (base_options[:number_of_shards] || 1) * 2)
  12. end
  13. end
  14. end
  15. end
  16. Chewy::Index.extend(Chewy::IndexExtensions)