Add `ES_PRESET` option to customize numbers of shards and replicas (#26483)
Co-authored-by: Eugen Rochko <eugen@zeonfederated.com>local
parent
c452ccd913
commit
f5778caa3a
8 changed files with 35 additions and 12 deletions
@ -0,0 +1,18 @@ |
|||||||
|
# frozen_string_literal: true |
||||||
|
|
||||||
|
module Chewy |
||||||
|
module IndexExtensions |
||||||
|
def index_preset(base_options = {}) |
||||||
|
case ENV['ES_PRESET'].presence |
||||||
|
when 'single_node_cluster', nil |
||||||
|
base_options.merge(number_of_replicas: 0) |
||||||
|
when 'small_cluster' |
||||||
|
base_options.merge(number_of_replicas: 1) |
||||||
|
when 'large_cluster' |
||||||
|
base_options.merge(number_of_replicas: 1, number_of_shards: (base_options[:number_of_shards] || 1) * 2) |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
Chewy::Index.extend(Chewy::IndexExtensions) |
@ -0,0 +1,11 @@ |
|||||||
|
# frozen_string_literal: true |
||||||
|
|
||||||
|
module Chewy |
||||||
|
module SettingsExtensions |
||||||
|
def enabled? |
||||||
|
settings[:enabled] |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
Chewy.extend(Chewy::SettingsExtensions) |
Loading…
Reference in new issue