Skip to content

Commit

Permalink
feat: add --optimize and --no-optimize option the index reset cli com…
Browse files Browse the repository at this point in the history
…mand
  • Loading branch information
marcosgz committed Jul 12, 2024
1 parent 3cdb548 commit 707b264
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
esse (0.3.2)
esse (0.3.3)
multi_json
thor (>= 0.19)

Expand Down
1 change: 1 addition & 0 deletions lib/esse/cli/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Index < Base
DESC
option :suffix, type: :string, default: nil, aliases: '-s', desc: 'Suffix to append to index name'
option :import, type: :boolean, default: true, desc: 'Import documents before point alias to the new index'
option :optimize, type: :boolean, default: true, desc: 'Optimize index before import documents by disabling refresh_interval and setting number_of_replicas to 0'
def reset(*index_classes)
require_relative 'index/reset'
Reset.new(indices: index_classes, **options.to_h.transform_keys(&:to_sym)).run
Expand Down
7 changes: 6 additions & 1 deletion spec/esse/cli/index/reset_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
end

specify do
expect(CountiesIndex).to receive(:reset_index).with(suffix: 'foo', import: true).and_return(true)
expect(CountiesIndex).to receive(:reset_index).with(suffix: 'foo', import: true, optimize: true).and_return(true)
cli_exec(%w[index reset CountiesIndex --suffix=foo])
end

Expand All @@ -50,6 +50,11 @@
expect(CountiesIndex).to receive(:reset_index).and_return(true)
cli_exec(%w[index reset all])
end

specify do
expect(CountiesIndex).to receive(:reset_index).with(import: true, optimize: false).and_return(true)
cli_exec(%w[index reset CountiesIndex --no-optimize])
end
end
end
end

0 comments on commit 707b264

Please sign in to comment.