Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add swap_indexes method #393

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/meilisearch/client.rb
Expand Up @@ -12,6 +12,12 @@ def raw_indexes(options = {})
http_get('/indexes', body)
end

def swap_indexes(*options)
mapped_array = options.map { |arr| { indexes: arr } }

http_post '/swap-indexes', mapped_array
end

def indexes(options = {})
response = raw_indexes(options)

Expand Down
11 changes: 11 additions & 0 deletions spec/meilisearch/client/indexes_spec.rb
Expand Up @@ -237,4 +237,15 @@
end
end
end

describe '#swap_indexes' do
it 'swaps two indexes' do
task = client.swap_indexes(['indexA', 'indexB'], ['indexC', 'indexD'])
task = client.wait_for_task(task['taskUid'])

expect(task['type']).to eq('indexSwap')
expect(task['details']['swaps']).to eq([{ 'indexes' => ['indexA', 'indexB'] },
{ 'indexes' => ['indexC', 'indexD'] }])
end
end
end