-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reset index using
/_reindex
API (#21)
* chore: add --reindex option to the cli index reset command * feat: Add reindex action to transport api * feat: new functionality to reindex data using _reindex API after reset
- Loading branch information
Showing
13 changed files
with
214 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
spec/esse/integrations/elasticsearch-5/transport/reindex_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
require 'support/shared_examples/transport_reindex' | ||
|
||
stack_describe 'elasticsearch', '5.x', Esse::Transport, '#reindex' do | ||
include_examples 'transport#reindex' | ||
end |
8 changes: 8 additions & 0 deletions
8
spec/esse/integrations/elasticsearch-6/transport/reindex_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
require 'support/shared_examples/transport_reindex' | ||
|
||
stack_describe 'elasticsearch', '6.x', Esse::Transport, '#reindex' do | ||
include_examples 'transport#reindex' | ||
end |
8 changes: 8 additions & 0 deletions
8
spec/esse/integrations/elasticsearch-7/transport/reindex_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
require 'support/shared_examples/transport_reindex' | ||
|
||
stack_describe 'elasticsearch', '7.x', Esse::Transport, '#reindex' do | ||
include_examples 'transport#reindex' | ||
end |
8 changes: 8 additions & 0 deletions
8
spec/esse/integrations/elasticsearch-8/transport/reindex_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
require 'support/shared_examples/transport_reindex' | ||
|
||
stack_describe 'elasticsearch', '8.x', Esse::Transport, '#reindex' do | ||
include_examples 'transport#reindex' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.shared_examples 'transport#reindex' do | ||
let(:body) do | ||
{ | ||
settings: { | ||
index: { | ||
number_of_shards: 1, | ||
number_of_replicas: 0 | ||
} | ||
} | ||
} | ||
end | ||
|
||
it 'raises an Esse::Transport::ReadonlyClusterError exception when the cluster is readonly' do | ||
es_client do |client, _conf, cluster| | ||
cluster.warm_up! | ||
expect(client).not_to receive(:perform_request) | ||
cluster.readonly = true | ||
expect { | ||
cluster.api.reindex(body: { source: { index: "#{cluster.index_prefix}_ro_from" }, dest: { index: "#{cluster.index_prefix}_ro_to" } }) | ||
}.to raise_error(Esse::Transport::ReadonlyClusterError) | ||
end | ||
end | ||
|
||
it 'raises an #<Esse::Transport::NotFoundError exception when the source index does not exist' do | ||
es_client do |_client, _conf, cluster| | ||
expect { | ||
cluster.api.reindex(body: { source: { index: "#{cluster.index_prefix}_non_existent_index" }, dest: { index: "#{cluster.index_prefix}_to" } }) | ||
}.to raise_error(Esse::Transport::NotFoundError) | ||
end | ||
end | ||
|
||
context 'when the source index exists' do | ||
it 'reindexes the source index to the destination index' do | ||
es_client do |client, _conf, cluster| | ||
source_index = "#{cluster.index_prefix}_reindex_from" | ||
dest_index = "#{cluster.index_prefix}_reindex_to" | ||
cluster.api.create_index(index: source_index, body: body) | ||
cluster.api.create_index(index: dest_index, body: body) | ||
cluster.api.index(index: source_index, id: 1, body: { title: 'foo' }, refresh: true) | ||
|
||
resp = nil | ||
expect { | ||
resp = cluster.api.reindex(body: { source: { index: source_index }, dest: { index: dest_index } }, refresh: true) | ||
}.not_to raise_error | ||
expect(resp['total']).to eq(1) | ||
|
||
resp = cluster.api.get(index: dest_index, id: 1, _source: false) | ||
expect(resp['found']).to eq(true) | ||
end | ||
end | ||
end | ||
end |