elasticsearch-api 0.4.11 → 1.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -6
- data/README.md +3 -4
- data/lib/elasticsearch/api.rb +16 -9
- data/lib/elasticsearch/api/actions/cat/aliases.rb +67 -0
- data/lib/elasticsearch/api/actions/cat/allocation.rb +69 -0
- data/lib/elasticsearch/api/actions/cat/count.rb +59 -0
- data/lib/elasticsearch/api/actions/cat/health.rb +43 -0
- data/lib/elasticsearch/api/actions/cat/help.rb +25 -0
- data/lib/elasticsearch/api/actions/cat/indices.rb +77 -0
- data/lib/elasticsearch/api/actions/cat/master.rb +40 -0
- data/lib/elasticsearch/api/actions/cat/nodes.rb +38 -0
- data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +40 -0
- data/lib/elasticsearch/api/actions/cat/recovery.rb +73 -0
- data/lib/elasticsearch/api/actions/cat/shards.rb +72 -0
- data/lib/elasticsearch/api/actions/cluster/put_settings.rb +3 -1
- data/lib/elasticsearch/api/actions/cluster/state.rb +23 -14
- data/lib/elasticsearch/api/actions/count_percolate.rb +78 -0
- data/lib/elasticsearch/api/actions/indices/exists.rb +4 -1
- data/lib/elasticsearch/api/actions/indices/exists_alias.rb +5 -3
- data/lib/elasticsearch/api/actions/indices/exists_template.rb +34 -0
- data/lib/elasticsearch/api/actions/indices/exists_type.rb +4 -1
- data/lib/elasticsearch/api/actions/indices/get_alias.rb +5 -3
- data/lib/elasticsearch/api/actions/indices/get_aliases.rb +6 -3
- data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +2 -1
- data/lib/elasticsearch/api/actions/indices/get_mapping.rb +8 -3
- data/lib/elasticsearch/api/actions/indices/get_settings.rb +7 -2
- data/lib/elasticsearch/api/actions/indices/get_warmer.rb +0 -2
- data/lib/elasticsearch/api/actions/indices/put_alias.rb +0 -1
- data/lib/elasticsearch/api/actions/indices/put_mapping.rb +11 -4
- data/lib/elasticsearch/api/actions/indices/put_warmer.rb +0 -1
- data/lib/elasticsearch/api/actions/mpercolate.rb +58 -0
- data/lib/elasticsearch/api/actions/mtermvectors.rb +67 -0
- data/lib/elasticsearch/api/actions/{cluster/node_hot_threads.rb → nodes/hot_threads.rb} +3 -3
- data/lib/elasticsearch/api/actions/{cluster/node_info.rb → nodes/info.rb} +3 -3
- data/lib/elasticsearch/api/actions/{cluster/node_shutdown.rb → nodes/shutdown.rb} +3 -3
- data/lib/elasticsearch/api/actions/nodes/stats.rb +79 -0
- data/lib/elasticsearch/api/actions/percolate.rb +67 -21
- data/lib/elasticsearch/api/actions/snapshot/create.rb +48 -0
- data/lib/elasticsearch/api/actions/snapshot/create_repository.rb +44 -0
- data/lib/elasticsearch/api/actions/snapshot/delete.rb +41 -0
- data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +38 -0
- data/lib/elasticsearch/api/actions/snapshot/get.rb +47 -0
- data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +42 -0
- data/lib/elasticsearch/api/actions/snapshot/restore.rb +53 -0
- data/lib/elasticsearch/api/actions/termvector.rb +77 -0
- data/lib/elasticsearch/api/namespace/cat.rb +20 -0
- data/lib/elasticsearch/api/namespace/nodes.rb +20 -0
- data/lib/elasticsearch/api/namespace/snapshot.rb +20 -0
- data/lib/elasticsearch/api/utils.rb +2 -4
- data/lib/elasticsearch/api/version.rb +1 -1
- data/test/integration/yaml_test_runner.rb +37 -8
- data/test/unit/cat/aliases_test.rb +26 -0
- data/test/unit/cat/allocation_test.rb +26 -0
- data/test/unit/cat/count_test.rb +26 -0
- data/test/unit/cat/health_test.rb +26 -0
- data/test/unit/cat/help_test.rb +26 -0
- data/test/unit/cat/indices_test.rb +26 -0
- data/test/unit/cat/master_test.rb +26 -0
- data/test/unit/cat/nodes_test.rb +26 -0
- data/test/unit/cat/pending_tasks_test.rb +26 -0
- data/test/unit/cat/recovery_test.rb +26 -0
- data/test/unit/cat/shards_test.rb +26 -0
- data/test/unit/cluster/state_test.rb +12 -3
- data/test/unit/count_percolate_test.rb +26 -0
- data/test/unit/indices/exists_alias_test.rb +0 -6
- data/test/unit/indices/exists_template_test.rb +59 -0
- data/test/unit/indices/get_alias_test.rb +0 -6
- data/test/unit/indices/get_aliases_test.rb +10 -0
- data/test/unit/indices/get_field_mapping_test.rb +1 -1
- data/test/unit/indices/get_mapping_test.rb +3 -3
- data/test/unit/indices/get_settings_test.rb +10 -0
- data/test/unit/indices/get_warmer_test.rb +0 -6
- data/test/unit/indices/put_alias_test.rb +0 -6
- data/test/unit/indices/put_mapping_test.rb +5 -11
- data/test/unit/indices/put_settings_test.rb +9 -0
- data/test/unit/indices/put_warmer_test.rb +0 -6
- data/test/unit/mpercolate_test.rb +51 -0
- data/test/unit/mtermvectors_test.rb +38 -0
- data/test/unit/{cluster/node_hot_threads_test.rb → nodes/hot_threads_test.rb} +5 -5
- data/test/unit/{cluster/node_info_test.rb → nodes/info_test.rb} +6 -6
- data/test/unit/{cluster/node_shutdown_test.rb → nodes/shutdown_test.rb} +6 -6
- data/test/unit/{cluster/node_stats_test.rb → nodes/stats_test.rb} +10 -10
- data/test/unit/percolate_test.rb +2 -13
- data/test/unit/snapshot/create_repository_test.rb +38 -0
- data/test/unit/snapshot/create_test.rb +38 -0
- data/test/unit/snapshot/delete_repository_test.rb +35 -0
- data/test/unit/snapshot/delete_test.rb +38 -0
- data/test/unit/snapshot/get_repository_test.rb +26 -0
- data/test/unit/snapshot/get_test.rb +38 -0
- data/test/unit/snapshot/restore_test.rb +38 -0
- data/test/unit/termvector_test.rb +44 -0
- data/test/unit/utils_test.rb +11 -0
- metadata +89 -17
- data/lib/elasticsearch/api/actions/cluster/node_stats.rb +0 -75
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class CatShardsTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Cat: Shards" 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 'GET', method
|
13
|
+
assert_equal '_cat/shards', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_nil body
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.cat.shards
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -19,15 +19,24 @@ module Elasticsearch
|
|
19
19
|
subject.cluster.state
|
20
20
|
end
|
21
21
|
|
22
|
+
should "build the correct path" do
|
23
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
24
|
+
assert_equal '_cluster/state/foo,bar', url
|
25
|
+
assert_equal({}, params)
|
26
|
+
true
|
27
|
+
end.returns(FakeResponse.new)
|
28
|
+
|
29
|
+
subject.cluster.state :metric => ['foo', 'bar']
|
30
|
+
end
|
31
|
+
|
22
32
|
should "send the API parameters" do
|
23
33
|
subject.expects(:perform_request).with do |method, url, params, body|
|
24
|
-
assert_equal 'GET', method
|
25
34
|
assert_equal '_cluster/state', url
|
26
|
-
assert_equal({:
|
35
|
+
assert_equal({:index_templates => 'foo,bar'}, params)
|
27
36
|
true
|
28
37
|
end.returns(FakeResponse.new)
|
29
38
|
|
30
|
-
subject.cluster.state :
|
39
|
+
subject.cluster.state :index_templates => ['foo', 'bar']
|
31
40
|
end
|
32
41
|
|
33
42
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class CountPercolateTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Count percolate" 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 'GET', method
|
13
|
+
assert_equal 'foo/bar/_percolate/count', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_equal 'bar', body[:doc][:foo]
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.count_percolate :index => 'foo', :type => 'bar', :body => { :doc => { :foo => 'bar' } }
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -7,12 +7,6 @@ module Elasticsearch
|
|
7
7
|
context "Indices: Exists alias" do
|
8
8
|
subject { FakeClient.new }
|
9
9
|
|
10
|
-
should "require the :name argument" do
|
11
|
-
assert_raise ArgumentError do
|
12
|
-
subject.indices.delete_mapping
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
10
|
should "perform correct request" do
|
17
11
|
subject.expects(:perform_request).with do |method, url, params, body|
|
18
12
|
assert_equal 'HEAD', method
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class IndicesExistsTemplateTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Indices: Exists template" 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 'HEAD', method
|
13
|
+
assert_equal '_template/foo', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_nil body
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.indices.exists_template :name => 'foo'
|
20
|
+
end
|
21
|
+
|
22
|
+
should "URL-escape the parts" do
|
23
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
24
|
+
assert_equal '_template/bar%2Fbam', url
|
25
|
+
true
|
26
|
+
end.returns(FakeResponse.new)
|
27
|
+
|
28
|
+
subject.indices.exists_template :name => 'bar/bam'
|
29
|
+
end
|
30
|
+
|
31
|
+
should "return true for successful response" do
|
32
|
+
subject.expects(:perform_request).returns(FakeResponse.new 200, 'OK')
|
33
|
+
assert_equal true, subject.indices.exists_template(:name => 'bar')
|
34
|
+
end
|
35
|
+
|
36
|
+
should "return false for 404 response" do
|
37
|
+
subject.expects(:perform_request).returns(FakeResponse.new 404, 'Not Found')
|
38
|
+
assert_equal false, subject.indices.exists_template(:name => 'none')
|
39
|
+
end
|
40
|
+
|
41
|
+
should "return false on 'not found' exceptions" do
|
42
|
+
subject.expects(:perform_request).raises(StandardError.new '404 NotFound')
|
43
|
+
assert_nothing_raised do
|
44
|
+
assert_equal false, subject.indices.exists_template(:name => 'none')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
should "re-raise generic exceptions" do
|
49
|
+
subject.expects(:perform_request).raises(StandardError)
|
50
|
+
assert_raise(StandardError) do
|
51
|
+
assert_equal false, subject.indices.exists_template(:name => 'none')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -7,12 +7,6 @@ module Elasticsearch
|
|
7
7
|
context "Indices: Get alias" do
|
8
8
|
subject { FakeClient.new }
|
9
9
|
|
10
|
-
should "require the :name argument" do
|
11
|
-
assert_raise ArgumentError do
|
12
|
-
subject.indices.get_alias
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
10
|
should "perform correct request" do
|
17
11
|
subject.expects(:perform_request).with do |method, url, params, body|
|
18
12
|
assert_equal 'GET', method
|
@@ -28,6 +28,16 @@ module Elasticsearch
|
|
28
28
|
subject.indices.get_aliases :index => 'foo'
|
29
29
|
end
|
30
30
|
|
31
|
+
should "get a specific alias" do
|
32
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
33
|
+
assert_equal 'foo/_aliases/bar', url
|
34
|
+
assert_equal Hash.new, params
|
35
|
+
true
|
36
|
+
end.returns(FakeResponse.new)
|
37
|
+
|
38
|
+
subject.indices.get_aliases :index => 'foo', :name => 'bar'
|
39
|
+
end
|
40
|
+
|
31
41
|
should "URL-escape the parts" do
|
32
42
|
subject.expects(:perform_request).with do |method, url, params, body|
|
33
43
|
assert_equal 'foo%5Ebar/_aliases', url
|
@@ -30,7 +30,7 @@ module Elasticsearch
|
|
30
30
|
|
31
31
|
should "perform request against an index and type" do
|
32
32
|
subject.expects(:perform_request).with do |method, url, params, body|
|
33
|
-
assert_equal 'foo/bar/
|
33
|
+
assert_equal 'foo/_mapping/bar/field/bam', url
|
34
34
|
true
|
35
35
|
end.returns(FakeResponse.new)
|
36
36
|
|
@@ -30,7 +30,7 @@ module Elasticsearch
|
|
30
30
|
|
31
31
|
should "perform request against an index and type" do
|
32
32
|
subject.expects(:perform_request).with do |method, url, params, body|
|
33
|
-
assert_equal 'foo/bar
|
33
|
+
assert_equal 'foo/_mapping/bar', url
|
34
34
|
true
|
35
35
|
end.returns(FakeResponse.new)
|
36
36
|
|
@@ -39,7 +39,7 @@ module Elasticsearch
|
|
39
39
|
|
40
40
|
should "perform request against multiple indices and types" do
|
41
41
|
subject.expects(:perform_request).with do |method, url, params, body|
|
42
|
-
assert_equal 'foo,bar/bam,baz
|
42
|
+
assert_equal 'foo,bar/_mapping/bam,baz', url
|
43
43
|
true
|
44
44
|
end.returns(FakeResponse.new)
|
45
45
|
|
@@ -48,7 +48,7 @@ module Elasticsearch
|
|
48
48
|
|
49
49
|
should "URL-escape the parts" do
|
50
50
|
subject.expects(:perform_request).with do |method, url, params, body|
|
51
|
-
assert_equal 'foo%5Ebar/bar%2Fbam
|
51
|
+
assert_equal 'foo%5Ebar/_mapping/bar%2Fbam', url
|
52
52
|
true
|
53
53
|
end.returns(FakeResponse.new)
|
54
54
|
|
@@ -37,6 +37,16 @@ module Elasticsearch
|
|
37
37
|
subject.indices.get_settings :index => 'foo^bar'
|
38
38
|
end
|
39
39
|
|
40
|
+
should "get specific settings" do
|
41
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
42
|
+
assert_equal 'foo/_settings/foo.bar', url
|
43
|
+
assert_equal Hash.new, params
|
44
|
+
true
|
45
|
+
end.returns(FakeResponse.new)
|
46
|
+
|
47
|
+
subject.indices.get_settings :index => 'foo', :name => 'foo.bar'
|
48
|
+
end
|
49
|
+
|
40
50
|
end
|
41
51
|
|
42
52
|
end
|
@@ -7,12 +7,6 @@ module Elasticsearch
|
|
7
7
|
context "Indices: Get warmer" do
|
8
8
|
subject { FakeClient.new }
|
9
9
|
|
10
|
-
should "require the :index argument" do
|
11
|
-
assert_raise ArgumentError do
|
12
|
-
subject.indices.get_warmer :name => 'foo'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
10
|
should "perform correct request" do
|
17
11
|
subject.expects(:perform_request).with do |method, url, params, body|
|
18
12
|
assert_equal 'GET', method
|
@@ -7,12 +7,6 @@ module Elasticsearch
|
|
7
7
|
context "Indices: Put alias" do
|
8
8
|
subject { FakeClient.new }
|
9
9
|
|
10
|
-
should "require the :index argument" do
|
11
|
-
assert_raise ArgumentError do
|
12
|
-
subject.indices.put_alias :name => 'bar'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
10
|
should "require the :name argument" do
|
17
11
|
assert_raise ArgumentError do
|
18
12
|
subject.indices.put_alias :index => 'foo'
|
@@ -7,22 +7,16 @@ module Elasticsearch
|
|
7
7
|
context "Indices: Put mapping" do
|
8
8
|
subject { FakeClient.new }
|
9
9
|
|
10
|
-
should "require the :index argument" do
|
11
|
-
assert_raise ArgumentError do
|
12
|
-
subject.indices.put_mapping :type => 'bar'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
10
|
should "require the :type argument" do
|
17
11
|
assert_raise ArgumentError do
|
18
|
-
subject.indices.put_mapping :index => 'foo'
|
12
|
+
subject.indices.put_mapping :index => 'foo', :body => {}
|
19
13
|
end
|
20
14
|
end
|
21
15
|
|
22
16
|
should "perform correct request" do
|
23
17
|
subject.expects(:perform_request).with do |method, url, params, body|
|
24
18
|
assert_equal 'PUT', method
|
25
|
-
assert_equal 'foo/bar
|
19
|
+
assert_equal 'foo/_mapping/bar', url
|
26
20
|
assert_equal Hash.new, params
|
27
21
|
assert_equal({ :foo => {} }, body)
|
28
22
|
true
|
@@ -33,7 +27,7 @@ module Elasticsearch
|
|
33
27
|
|
34
28
|
should "perform request against multiple indices" do
|
35
29
|
subject.expects(:perform_request).with do |method, url, params, body|
|
36
|
-
assert_equal 'foo,bar/bam
|
30
|
+
assert_equal 'foo,bar/_mapping/bam', url
|
37
31
|
true
|
38
32
|
end.returns(FakeResponse.new)
|
39
33
|
|
@@ -42,7 +36,7 @@ module Elasticsearch
|
|
42
36
|
|
43
37
|
should "pass the URL parameters" do
|
44
38
|
subject.expects(:perform_request).with do |method, url, params, body|
|
45
|
-
assert_equal 'foo/bar
|
39
|
+
assert_equal 'foo/_mapping/bar', url
|
46
40
|
assert_equal true, params[:ignore_conflicts]
|
47
41
|
true
|
48
42
|
end.returns(FakeResponse.new)
|
@@ -52,7 +46,7 @@ module Elasticsearch
|
|
52
46
|
|
53
47
|
should "URL-escape the parts" do
|
54
48
|
subject.expects(:perform_request).with do |method, url, params, body|
|
55
|
-
assert_equal 'foo%5Ebar/bar%2Fbam
|
49
|
+
assert_equal 'foo%5Ebar/_mapping/bar%2Fbam', url
|
56
50
|
true
|
57
51
|
end.returns(FakeResponse.new)
|
58
52
|
|
@@ -25,6 +25,15 @@ module Elasticsearch
|
|
25
25
|
subject.indices.put_settings :body => {}
|
26
26
|
end
|
27
27
|
|
28
|
+
should "perform request with parameters" do
|
29
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
30
|
+
assert_equal true, params[:flat_settings]
|
31
|
+
true
|
32
|
+
end.returns(FakeResponse.new)
|
33
|
+
|
34
|
+
subject.indices.put_settings :index => 'foo', :flat_settings => true, :body => {}
|
35
|
+
end
|
36
|
+
|
28
37
|
should "perform request against a specific indices" do
|
29
38
|
subject.expects(:perform_request).with do |method, url, params, body|
|
30
39
|
assert_equal 'foo/_settings', url
|
@@ -7,12 +7,6 @@ module Elasticsearch
|
|
7
7
|
context "Indices: Put warmer" do
|
8
8
|
subject { FakeClient.new }
|
9
9
|
|
10
|
-
should "require the :index argument" do
|
11
|
-
assert_raise ArgumentError do
|
12
|
-
subject.indices.put_warmer :name => 'foo', :body => {}
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
10
|
should "require the :name argument" do
|
17
11
|
assert_raise ArgumentError do
|
18
12
|
subject.indices.put_warmer :index => 'foo', :body => {}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class MpercolateTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Mpercolate" do
|
8
|
+
subject { FakeClient.new }
|
9
|
+
|
10
|
+
should "require the :body argument" do
|
11
|
+
assert_raise ArgumentError do
|
12
|
+
subject.mpercolate
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
should "post correct payload to the endpoint" do
|
17
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
18
|
+
assert_equal 'GET', method
|
19
|
+
assert_equal '_mpercolate', url
|
20
|
+
assert_equal Hash.new, params
|
21
|
+
|
22
|
+
lines = body.split("\n")
|
23
|
+
assert_match /\{"percolate"/, lines[0]
|
24
|
+
assert_match /\{"doc"/, lines[1]
|
25
|
+
assert_match /\{"percolate"/, lines[2]
|
26
|
+
assert_match /\{\}/, lines[3]
|
27
|
+
true
|
28
|
+
end.returns(FakeResponse.new)
|
29
|
+
|
30
|
+
subject.mpercolate :body => [
|
31
|
+
{ :percolate => { :index => "my-index", :type => "my-type" } },
|
32
|
+
{ :doc => { :message => "foo bar" } },
|
33
|
+
{ :percolate => { :index => "my-other-index", :type => "my-other-type", :id => "1" } },
|
34
|
+
{ }
|
35
|
+
]
|
36
|
+
end
|
37
|
+
|
38
|
+
should "post a string payload intact" do
|
39
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
40
|
+
assert_equal %Q|{"foo":"bar"}\n{"moo":"lam"}|, body
|
41
|
+
true
|
42
|
+
end.returns(FakeResponse.new)
|
43
|
+
|
44
|
+
subject.mpercolate :body => %Q|{"foo":"bar"}\n{"moo":"lam"}|
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class MtermvectorsTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Mtermvectors" 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 'GET', method
|
13
|
+
assert_equal 'my-index/my-type/_mtermvectors', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_equal [1, 2, 3], body[:ids]
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.mtermvectors :index => 'my-index', :type => 'my-type', :body => { :ids => [1, 2, 3] }
|
20
|
+
end
|
21
|
+
|
22
|
+
should "allow passing a list of IDs instead of the body" do
|
23
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
24
|
+
assert_equal 'GET', method
|
25
|
+
assert_equal 'my-index/my-type/_mtermvectors', url
|
26
|
+
assert_equal Hash.new, params
|
27
|
+
assert_equal [1, 2, 3], body[:ids]
|
28
|
+
true
|
29
|
+
end.returns(FakeResponse.new)
|
30
|
+
|
31
|
+
subject.mtermvectors :index => 'my-index', :type => 'my-type', :ids => [1, 2, 3]
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|