Skip to content

Commit 798ef25

Browse files
committed
[API] Added the "Upgrade Index" API
1 parent b3dba4a commit 798ef25

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
module Elasticsearch
2+
module API
3+
module Indices
4+
module Actions
5+
6+
# Upgrade the index or indices to the latest Lucene format.
7+
#
8+
# @option arguments [List] :index A comma-separated list of index names;
9+
# use `_all` or empty string to perform the operation on all indices
10+
# @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored
11+
# when unavailable (missing or closed)
12+
# @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression
13+
# resolves into no concrete indices.
14+
# @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices
15+
# that are open, closed or both. (options: open, closed)
16+
# @option arguments [Boolean] :wait_for_completion Specify whether the request should block until the all
17+
# segments are upgraded (default: true)
18+
#
19+
# @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/indices-upgrade.html
20+
#
21+
def upgrade(arguments={})
22+
valid_params = [
23+
:ignore_unavailable,
24+
:allow_no_indices,
25+
:expand_wildcards,
26+
:wait_for_completion ]
27+
28+
method = 'POST'
29+
path = "_upgrade"
30+
params = Utils.__validate_and_extract_params arguments, valid_params
31+
body = nil
32+
33+
perform_request(method, path, params, body).body
34+
end
35+
end
36+
end
37+
end
38+
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require 'test_helper'
2+
3+
module Elasticsearch
4+
module Test
5+
class IndicesUpgradeTest < ::Test::Unit::TestCase
6+
7+
context "Indices: Upgrade" do
8+
subject { FakeClient.new }
9+
10+
should "perform correct request" do
11+
subject.expects(:perform_request).with do |method, url, params, body|
12+
assert_equal 'POST', method
13+
assert_equal '_upgrade', url
14+
assert_equal Hash.new, params
15+
assert_nil body
16+
true
17+
end.returns(FakeResponse.new)
18+
19+
subject.indices.upgrade
20+
end
21+
22+
end
23+
24+
end
25+
end
26+
end

0 commit comments

Comments
 (0)