elasticsearch-api 6.0.1 → 6.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba7cd7dc9a07db583b12281c41cf5d612ed43f02
4
- data.tar.gz: 2fedb5c237669e77184ab1e7bff1df3cb324614e
3
+ metadata.gz: 68a87daeb6c52cecf38a0caa2a6c3c3bb935bd5b
4
+ data.tar.gz: 9a54edd2550c5d268444410135bdb207ef908e9c
5
5
  SHA512:
6
- metadata.gz: e963573fb73b41056f6fe8af032d5fa2b0f6818a5ea1f0f7ebb80a03e78745d946897b0cb3ca103763f2fcb53817d92e55f30b5abef01899f87a1bbd8392447f
7
- data.tar.gz: 5dde0d7b48b370a27d7c25aa418d1d00ac982fb6242c594aa7fad6665f7b020539cb0cfcd5dfb0970f39b7638ac9cc404ac2c69da634da144b78a1365bd988bd
6
+ metadata.gz: c0d66648a591014cf42d03794bd8c012da7013e0342e13688d2eda2fa9de0f571a3c5abea813331db2370580a647b13ecfb14780e41ff0ae84fea56e13885381
7
+ data.tar.gz: 25d7bb747ab4c3fb4c058bd998da4bcbe54359ca85354d73c0d2f10595f5b6d77c24bbaa1a3462c9256f211b915e7766277ab47f71060b00bc6f96f0b1d247a8
@@ -92,7 +92,7 @@ module Elasticsearch
92
92
  payload = body
93
93
  end
94
94
 
95
- perform_request(method, path, params, payload).body
95
+ perform_request(method, path, params, payload, {"Content-Type" => "application/x-ndjson"}).body
96
96
  end
97
97
  end
98
98
  end
@@ -26,6 +26,8 @@ module Elasticsearch
26
26
  # shards is finished
27
27
  # @option arguments [Boolean] :wait_for_no_relocating_shards Whether to wait until there are no relocating
28
28
  # shards in the cluster
29
+ # @option arguments [Boolean] :wait_for_no_initializing_shards Whether to wait until there are no
30
+ # initializing shards in the cluster
29
31
  # @option arguments [String] :wait_for_status Wait until cluster is in a specific state
30
32
  # (options: green, yellow, red)
31
33
  # @option arguments [List] :wait_for_events Wait until all currently queued events with the given priorty
@@ -46,6 +48,7 @@ module Elasticsearch
46
48
  :wait_for_nodes,
47
49
  :wait_for_relocating_shards,
48
50
  :wait_for_no_relocating_shards,
51
+ :wait_for_no_initializing_shards,
49
52
  :wait_for_status,
50
53
  :wait_for_events ]
51
54
 
@@ -21,6 +21,7 @@ module Elasticsearch
21
21
  # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
22
22
  # unavailable (missing, closed, etc)
23
23
  # @option arguments [Time] :timeout Explicit operation timeout
24
+ # @option arguments [Number] :wait_for_active_shards Wait until the specified number of shards is active
24
25
  #
25
26
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-open-close/
26
27
  #
@@ -32,7 +33,8 @@ module Elasticsearch
32
33
  :ignore_unavailable,
33
34
  :allow_no_indices,
34
35
  :expand_wildcards,
35
- :timeout
36
+ :timeout,
37
+ :wait_for_active_shards
36
38
  ]
37
39
 
38
40
  method = HTTP_POST
@@ -0,0 +1,35 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Indices
4
+ module Actions
5
+
6
+ # The split index API allows you to split an existing index into a new index,
7
+ # where each original primary shard is split into two or more primary shards in the new index.
8
+ #
9
+ # @option arguments [String] :index The name of the source index to split (*Required*)
10
+ # @option arguments [String] :target The name of the target index to split into (*Required*)
11
+ # @option arguments [Hash] :body The configuration for the target index (`settings` and `aliases`)
12
+ # @option arguments [Time] :timeout Explicit operation timeout
13
+ # @option arguments [Time] :master_timeout Specify timeout for connection to master
14
+ # @option arguments [String] :wait_for_active_shards Set the number of active shards to wait for on the shrunken index before the operation returns.
15
+ #
16
+ # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-split-index.html
17
+ #
18
+ def split(arguments={})
19
+ raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
20
+ raise ArgumentError, "Required argument 'target' missing" unless arguments[:target]
21
+ valid_params = [
22
+ :timeout,
23
+ :master_timeout,
24
+ :wait_for_active_shards ]
25
+ method = HTTP_PUT
26
+ path = Utils.__pathify Utils.__escape(arguments[:index]), '_split', Utils.__escape(arguments[:target])
27
+ params = Utils.__validate_and_extract_params arguments, valid_params
28
+ body = arguments[:body]
29
+
30
+ perform_request(method, path, params, body).body
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -71,7 +71,7 @@ module Elasticsearch
71
71
  payload = body
72
72
  end
73
73
 
74
- perform_request(method, path, params, payload).body
74
+ perform_request(method, path, params, payload, {"Content-Type" => "application/x-ndjson"}).body
75
75
  end
76
76
  end
77
77
  end
@@ -38,7 +38,7 @@ module Elasticsearch
38
38
  payload = body
39
39
  end
40
40
 
41
- perform_request(method, path, params, payload).body
41
+ perform_request(method, path, params, payload, {"Content-Type" => "application/x-ndjson"}).body
42
42
  end
43
43
  end
44
44
  end
@@ -43,9 +43,11 @@ module Elasticsearch
43
43
  # @option arguments [String] :consistency Explicit write consistency setting for the operation
44
44
  # (Options: one, quorum, all)
45
45
  # @option arguments [Boolean] :wait_for_completion Whether the request should block and wait until
46
- # the operation has completed
46
+ # the operation has completed
47
47
  # @option arguments [Float] :requests_per_second The throttling for this request in sub-requests per second.
48
48
  # 0 means set no throttling (default)
49
+ # @option arguments [Integer] :slices The number of slices this request should be divided into.
50
+ # Defaults to 1 meaning the request isn't sliced into sub-requests.
49
51
  #
50
52
  # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html
51
53
  #
@@ -56,7 +58,8 @@ module Elasticsearch
56
58
  :timeout,
57
59
  :consistency,
58
60
  :wait_for_completion,
59
- :requests_per_second ]
61
+ :requests_per_second,
62
+ :slices ]
60
63
  method = 'POST'
61
64
  path = "_reindex"
62
65
  params = Utils.__validate_and_extract_params arguments, valid_params
@@ -61,6 +61,7 @@ module Elasticsearch
61
61
  # @option arguments [Integer] :scroll_size Size on the scroll request powering the update_by_query
62
62
  # @option arguments [Boolean] :wait_for_completion Should the request should block until the reindex is complete.
63
63
  # @option arguments [Float] :requests_per_second The throttle for this request in sub-requests per second. 0 means set no throttle.
64
+ # @option arguments [Integer] :slices The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks.
64
65
  #
65
66
  # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html
66
67
  #
@@ -109,7 +110,8 @@ module Elasticsearch
109
110
  :consistency,
110
111
  :scroll_size,
111
112
  :wait_for_completion,
112
- :requests_per_second ]
113
+ :requests_per_second,
114
+ :slices ]
113
115
 
114
116
  method = HTTP_POST
115
117
 
@@ -17,8 +17,8 @@ module Elasticsearch
17
17
 
18
18
  # Delegates the `perform_request` method to the wrapped client
19
19
  #
20
- def perform_request(method, path, params={}, body=nil)
21
- client.perform_request method, path, params, body
20
+ def perform_request(method, path, params={}, body=nil, headers=nil)
21
+ client.perform_request method, path, params, body, headers
22
22
  end
23
23
  end
24
24
 
@@ -1,5 +1,5 @@
1
1
  module Elasticsearch
2
2
  module API
3
- VERSION = "6.0.1"
3
+ VERSION = "6.0.3"
4
4
  end
5
5
  end
data/test/test_helper.rb CHANGED
@@ -46,8 +46,8 @@ module Elasticsearch
46
46
  class FakeClient
47
47
  include Elasticsearch::API
48
48
 
49
- def perform_request(method, path, params, body)
50
- puts "PERFORMING REQUEST:", "--> #{method.to_s.upcase} #{path} #{params} #{body}"
49
+ def perform_request(method, path, params, body, headers={"Content-Type" => "application/json"})
50
+ puts "PERFORMING REQUEST:", "--> #{method.to_s.upcase} #{path} #{params} #{body} #{headers}"
51
51
  FakeResponse.new(200, 'FAKE', {})
52
52
  end
53
53
  end
@@ -8,7 +8,7 @@ module Elasticsearch
8
8
  subject { FakeClient.new }
9
9
 
10
10
  should "post correct payload to the endpoint" do
11
- subject.expects(:perform_request).with do |method, url, params, body|
11
+ subject.expects(:perform_request).with do |method, url, params, body, headers|
12
12
  assert_equal 'POST', method
13
13
  assert_equal '_bulk', url
14
14
  assert_equal Hash.new, params
@@ -32,6 +32,7 @@ module Elasticsearch
32
32
  {"data":"MYDATA"}
33
33
  PAYLOAD
34
34
  end
35
+ assert_equal 'application/x-ndjson', headers["Content-Type"]
35
36
  true
36
37
  end.returns(FakeResponse.new)
37
38
 
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+ module Elasticsearch
4
+ module Test
5
+ class IndicesSplitTest < ::Test::Unit::TestCase
6
+
7
+ context "Indices: Split" 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 'FAKE', method
13
+ assert_equal 'test', url
14
+ assert_equal Hash.new, params
15
+ assert_equal Hash.new, body
16
+ true
17
+ end.returns(FakeResponse.new)
18
+
19
+ subject.indices.split :index => 'foo', :target => 'foo'
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -14,7 +14,7 @@ module Elasticsearch
14
14
  end
15
15
 
16
16
  should "serialize and post header/data pairs" do
17
- subject.expects(:perform_request).with do |method, url, params, body|
17
+ subject.expects(:perform_request).with do |method, url, params, body, headers|
18
18
  assert_equal 'GET', method
19
19
  assert_equal '_msearch/template', url
20
20
  assert_equal Hash.new, params
@@ -24,6 +24,7 @@ module Elasticsearch
24
24
  {"index":"bar"}
25
25
  {"id":"query_foo","params":{"q":"foo"}}
26
26
  PAYLOAD
27
+ assert_equal 'application/x-ndjson', headers["Content-Type"]
27
28
  true
28
29
  end.returns(FakeResponse.new)
29
30
 
@@ -14,7 +14,7 @@ module Elasticsearch
14
14
  end
15
15
 
16
16
  should "post correct payload to the endpoint" do
17
- subject.expects(:perform_request).with do |method, url, params, body|
17
+ subject.expects(:perform_request).with do |method, url, params, body, headers|
18
18
  assert_equal 'GET', method
19
19
  assert_equal '_msearch', url
20
20
  assert_equal Hash.new, params
@@ -26,6 +26,7 @@ module Elasticsearch
26
26
  {"search_type":"count"}
27
27
  {"facets":{"tags":{}}}
28
28
  PAYLOAD
29
+ assert_equal 'application/x-ndjson', headers["Content-Type"]
29
30
  true
30
31
  end.returns(FakeResponse.new)
31
32
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.1
4
+ version: 6.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-28 00:00:00.000000000 Z
11
+ date: 2018-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -439,6 +439,7 @@ files:
439
439
  - lib/elasticsearch/api/actions/indices/shard_stores.rb
440
440
  - lib/elasticsearch/api/actions/indices/shrink.rb
441
441
  - lib/elasticsearch/api/actions/indices/snapshot_index.rb
442
+ - lib/elasticsearch/api/actions/indices/split.rb
442
443
  - lib/elasticsearch/api/actions/indices/stats.rb
443
444
  - lib/elasticsearch/api/actions/indices/status.rb
444
445
  - lib/elasticsearch/api/actions/indices/update_aliases.rb
@@ -592,6 +593,7 @@ files:
592
593
  - test/unit/indices/shard_stores_test.rb
593
594
  - test/unit/indices/shrink_test.rb
594
595
  - test/unit/indices/snapshot_index_test.rb
596
+ - test/unit/indices/split_test.rb
595
597
  - test/unit/indices/stats_test.rb
596
598
  - test/unit/indices/status_test.rb
597
599
  - test/unit/indices/update_aliases_test.rb
@@ -770,6 +772,7 @@ test_files:
770
772
  - test/unit/indices/shard_stores_test.rb
771
773
  - test/unit/indices/shrink_test.rb
772
774
  - test/unit/indices/snapshot_index_test.rb
775
+ - test/unit/indices/split_test.rb
773
776
  - test/unit/indices/stats_test.rb
774
777
  - test/unit/indices/status_test.rb
775
778
  - test/unit/indices/update_aliases_test.rb