elasticsearch-api 0.4.11 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/Gemfile +2 -6
  2. data/README.md +3 -4
  3. data/lib/elasticsearch/api.rb +16 -9
  4. data/lib/elasticsearch/api/actions/cat/aliases.rb +67 -0
  5. data/lib/elasticsearch/api/actions/cat/allocation.rb +69 -0
  6. data/lib/elasticsearch/api/actions/cat/count.rb +59 -0
  7. data/lib/elasticsearch/api/actions/cat/health.rb +43 -0
  8. data/lib/elasticsearch/api/actions/cat/help.rb +25 -0
  9. data/lib/elasticsearch/api/actions/cat/indices.rb +77 -0
  10. data/lib/elasticsearch/api/actions/cat/master.rb +40 -0
  11. data/lib/elasticsearch/api/actions/cat/nodes.rb +38 -0
  12. data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +40 -0
  13. data/lib/elasticsearch/api/actions/cat/recovery.rb +73 -0
  14. data/lib/elasticsearch/api/actions/cat/shards.rb +72 -0
  15. data/lib/elasticsearch/api/actions/cluster/put_settings.rb +3 -1
  16. data/lib/elasticsearch/api/actions/cluster/state.rb +23 -14
  17. data/lib/elasticsearch/api/actions/count_percolate.rb +78 -0
  18. data/lib/elasticsearch/api/actions/indices/exists.rb +4 -1
  19. data/lib/elasticsearch/api/actions/indices/exists_alias.rb +5 -3
  20. data/lib/elasticsearch/api/actions/indices/exists_template.rb +34 -0
  21. data/lib/elasticsearch/api/actions/indices/exists_type.rb +4 -1
  22. data/lib/elasticsearch/api/actions/indices/get_alias.rb +5 -3
  23. data/lib/elasticsearch/api/actions/indices/get_aliases.rb +6 -3
  24. data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +2 -1
  25. data/lib/elasticsearch/api/actions/indices/get_mapping.rb +8 -3
  26. data/lib/elasticsearch/api/actions/indices/get_settings.rb +7 -2
  27. data/lib/elasticsearch/api/actions/indices/get_warmer.rb +0 -2
  28. data/lib/elasticsearch/api/actions/indices/put_alias.rb +0 -1
  29. data/lib/elasticsearch/api/actions/indices/put_mapping.rb +11 -4
  30. data/lib/elasticsearch/api/actions/indices/put_warmer.rb +0 -1
  31. data/lib/elasticsearch/api/actions/mpercolate.rb +58 -0
  32. data/lib/elasticsearch/api/actions/mtermvectors.rb +67 -0
  33. data/lib/elasticsearch/api/actions/{cluster/node_hot_threads.rb → nodes/hot_threads.rb} +3 -3
  34. data/lib/elasticsearch/api/actions/{cluster/node_info.rb → nodes/info.rb} +3 -3
  35. data/lib/elasticsearch/api/actions/{cluster/node_shutdown.rb → nodes/shutdown.rb} +3 -3
  36. data/lib/elasticsearch/api/actions/nodes/stats.rb +79 -0
  37. data/lib/elasticsearch/api/actions/percolate.rb +67 -21
  38. data/lib/elasticsearch/api/actions/snapshot/create.rb +48 -0
  39. data/lib/elasticsearch/api/actions/snapshot/create_repository.rb +44 -0
  40. data/lib/elasticsearch/api/actions/snapshot/delete.rb +41 -0
  41. data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +38 -0
  42. data/lib/elasticsearch/api/actions/snapshot/get.rb +47 -0
  43. data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +42 -0
  44. data/lib/elasticsearch/api/actions/snapshot/restore.rb +53 -0
  45. data/lib/elasticsearch/api/actions/termvector.rb +77 -0
  46. data/lib/elasticsearch/api/namespace/cat.rb +20 -0
  47. data/lib/elasticsearch/api/namespace/nodes.rb +20 -0
  48. data/lib/elasticsearch/api/namespace/snapshot.rb +20 -0
  49. data/lib/elasticsearch/api/utils.rb +2 -4
  50. data/lib/elasticsearch/api/version.rb +1 -1
  51. data/test/integration/yaml_test_runner.rb +37 -8
  52. data/test/unit/cat/aliases_test.rb +26 -0
  53. data/test/unit/cat/allocation_test.rb +26 -0
  54. data/test/unit/cat/count_test.rb +26 -0
  55. data/test/unit/cat/health_test.rb +26 -0
  56. data/test/unit/cat/help_test.rb +26 -0
  57. data/test/unit/cat/indices_test.rb +26 -0
  58. data/test/unit/cat/master_test.rb +26 -0
  59. data/test/unit/cat/nodes_test.rb +26 -0
  60. data/test/unit/cat/pending_tasks_test.rb +26 -0
  61. data/test/unit/cat/recovery_test.rb +26 -0
  62. data/test/unit/cat/shards_test.rb +26 -0
  63. data/test/unit/cluster/state_test.rb +12 -3
  64. data/test/unit/count_percolate_test.rb +26 -0
  65. data/test/unit/indices/exists_alias_test.rb +0 -6
  66. data/test/unit/indices/exists_template_test.rb +59 -0
  67. data/test/unit/indices/get_alias_test.rb +0 -6
  68. data/test/unit/indices/get_aliases_test.rb +10 -0
  69. data/test/unit/indices/get_field_mapping_test.rb +1 -1
  70. data/test/unit/indices/get_mapping_test.rb +3 -3
  71. data/test/unit/indices/get_settings_test.rb +10 -0
  72. data/test/unit/indices/get_warmer_test.rb +0 -6
  73. data/test/unit/indices/put_alias_test.rb +0 -6
  74. data/test/unit/indices/put_mapping_test.rb +5 -11
  75. data/test/unit/indices/put_settings_test.rb +9 -0
  76. data/test/unit/indices/put_warmer_test.rb +0 -6
  77. data/test/unit/mpercolate_test.rb +51 -0
  78. data/test/unit/mtermvectors_test.rb +38 -0
  79. data/test/unit/{cluster/node_hot_threads_test.rb → nodes/hot_threads_test.rb} +5 -5
  80. data/test/unit/{cluster/node_info_test.rb → nodes/info_test.rb} +6 -6
  81. data/test/unit/{cluster/node_shutdown_test.rb → nodes/shutdown_test.rb} +6 -6
  82. data/test/unit/{cluster/node_stats_test.rb → nodes/stats_test.rb} +10 -10
  83. data/test/unit/percolate_test.rb +2 -13
  84. data/test/unit/snapshot/create_repository_test.rb +38 -0
  85. data/test/unit/snapshot/create_test.rb +38 -0
  86. data/test/unit/snapshot/delete_repository_test.rb +35 -0
  87. data/test/unit/snapshot/delete_test.rb +38 -0
  88. data/test/unit/snapshot/get_repository_test.rb +26 -0
  89. data/test/unit/snapshot/get_test.rb +38 -0
  90. data/test/unit/snapshot/restore_test.rb +38 -0
  91. data/test/unit/termvector_test.rb +44 -0
  92. data/test/unit/utils_test.rb +11 -0
  93. metadata +89 -17
  94. data/lib/elasticsearch/api/actions/cluster/node_stats.rb +0 -75
@@ -2,9 +2,9 @@ require 'test_helper'
2
2
 
3
3
  module Elasticsearch
4
4
  module Test
5
- class ClusterNodeHotThreadsTest < ::Test::Unit::TestCase
5
+ class NodesHotThreadsTest < ::Test::Unit::TestCase
6
6
 
7
- context "Cluster: Node hot threads" do
7
+ context "Nodes: Hot Threads" do
8
8
  subject { FakeClient.new }
9
9
 
10
10
  should "perform correct request" do
@@ -16,7 +16,7 @@ module Elasticsearch
16
16
  true
17
17
  end.returns(FakeResponse.new)
18
18
 
19
- subject.cluster.node_hot_threads
19
+ subject.nodes.hot_threads
20
20
  end
21
21
 
22
22
  should "send :node_id correctly" do
@@ -25,7 +25,7 @@ module Elasticsearch
25
25
  true
26
26
  end.returns(FakeResponse.new)
27
27
 
28
- subject.cluster.node_hot_threads :node_id => 'foo'
28
+ subject.nodes.hot_threads :node_id => 'foo'
29
29
  end
30
30
 
31
31
  should "URL-escape the parts" do
@@ -34,7 +34,7 @@ module Elasticsearch
34
34
  true
35
35
  end.returns(FakeResponse.new)
36
36
 
37
- subject.cluster.node_hot_threads :node_id => 'foo^bar'
37
+ subject.nodes.hot_threads :node_id => 'foo^bar'
38
38
  end
39
39
 
40
40
  end
@@ -2,9 +2,9 @@ require 'test_helper'
2
2
 
3
3
  module Elasticsearch
4
4
  module Test
5
- class ClusterNodeInfoTest < ::Test::Unit::TestCase
5
+ class NodesInfoTest < ::Test::Unit::TestCase
6
6
 
7
- context "Cluster: Node info" do
7
+ context "Nodes: Info" do
8
8
  subject { FakeClient.new }
9
9
 
10
10
  should "perform correct request" do
@@ -16,7 +16,7 @@ module Elasticsearch
16
16
  true
17
17
  end.returns(FakeResponse.new)
18
18
 
19
- subject.cluster.node_info
19
+ subject.nodes.info
20
20
  end
21
21
 
22
22
  should "send :node_id correctly" do
@@ -25,7 +25,7 @@ module Elasticsearch
25
25
  true
26
26
  end.returns(FakeResponse.new)
27
27
 
28
- subject.cluster.node_info :node_id => 'foo'
28
+ subject.nodes.info :node_id => 'foo'
29
29
  end
30
30
 
31
31
  should "send multiple :node_id-s correctly" do
@@ -34,8 +34,8 @@ module Elasticsearch
34
34
  true
35
35
  end.returns(FakeResponse.new).twice
36
36
 
37
- subject.cluster.node_info :node_id => 'A,B,C'
38
- subject.cluster.node_info :node_id => ['A', 'B', 'C']
37
+ subject.nodes.info :node_id => 'A,B,C'
38
+ subject.nodes.info :node_id => ['A', 'B', 'C']
39
39
  end
40
40
 
41
41
  end
@@ -2,9 +2,9 @@ require 'test_helper'
2
2
 
3
3
  module Elasticsearch
4
4
  module Test
5
- class ClusterNodeShutdownTest < ::Test::Unit::TestCase
5
+ class NodesShutdownTest < ::Test::Unit::TestCase
6
6
 
7
- context "Cluster: Node shutdown" do
7
+ context "Nodes: Shutdown" do
8
8
  subject { FakeClient.new }
9
9
 
10
10
  should "perform correct request" do
@@ -16,7 +16,7 @@ module Elasticsearch
16
16
  true
17
17
  end.returns(FakeResponse.new)
18
18
 
19
- subject.cluster.node_shutdown
19
+ subject.nodes.shutdown
20
20
  end
21
21
 
22
22
  should "send :node_id correctly" do
@@ -25,7 +25,7 @@ module Elasticsearch
25
25
  true
26
26
  end.returns(FakeResponse.new)
27
27
 
28
- subject.cluster.node_shutdown :node_id => 'foo'
28
+ subject.nodes.shutdown :node_id => 'foo'
29
29
  end
30
30
 
31
31
  should "send multiple :node_id-s correctly" do
@@ -34,8 +34,8 @@ module Elasticsearch
34
34
  true
35
35
  end.returns(FakeResponse.new).twice
36
36
 
37
- subject.cluster.node_shutdown :node_id => 'A,B,C'
38
- subject.cluster.node_shutdown :node_id => ['A', 'B', 'C']
37
+ subject.nodes.shutdown :node_id => 'A,B,C'
38
+ subject.nodes.shutdown :node_id => ['A', 'B', 'C']
39
39
  end
40
40
 
41
41
  end
@@ -2,9 +2,9 @@ require 'test_helper'
2
2
 
3
3
  module Elasticsearch
4
4
  module Test
5
- class ClusterNodeStatsTest < ::Test::Unit::TestCase
5
+ class NodesStatsTest < ::Test::Unit::TestCase
6
6
 
7
- context "Cluster: Node stats" do
7
+ context "Nodes: Stats" do
8
8
  subject { FakeClient.new }
9
9
 
10
10
  should "perform correct request" do
@@ -16,7 +16,7 @@ module Elasticsearch
16
16
  true
17
17
  end.returns(FakeResponse.new)
18
18
 
19
- subject.cluster.node_stats
19
+ subject.nodes.stats
20
20
  end
21
21
 
22
22
  should "send :node_id correctly" do
@@ -25,17 +25,17 @@ module Elasticsearch
25
25
  true
26
26
  end.returns(FakeResponse.new)
27
27
 
28
- subject.cluster.node_stats :node_id => 'foo'
28
+ subject.nodes.stats :node_id => 'foo'
29
29
  end
30
30
 
31
31
  should "get specific metric families" do
32
32
  subject.expects(:perform_request).with do |method, url, params, body|
33
- assert_equal '_nodes/stats', url
34
- assert_equal( {:http => true, :fs => true}, params )
33
+ assert_equal '_nodes/stats/http,fs', url
34
+ assert_equal( {}, params )
35
35
  true
36
36
  end.returns(FakeResponse.new)
37
37
 
38
- subject.cluster.node_stats :http => true, :fs => true
38
+ subject.nodes.stats :metric => [:http, :fs]
39
39
  end
40
40
 
41
41
  should "get specific metric for the indices family" do
@@ -44,7 +44,7 @@ module Elasticsearch
44
44
  true
45
45
  end.returns(FakeResponse.new)
46
46
 
47
- subject.cluster.node_stats :indices => true, :metric => 'filter_cache'
47
+ subject.nodes.stats :metric => :indices, :index_metric => 'filter_cache'
48
48
  end
49
49
 
50
50
  should "get fielddata statistics for the indices family" do
@@ -54,8 +54,8 @@ module Elasticsearch
54
54
  true
55
55
  end.returns(FakeResponse.new).twice
56
56
 
57
- subject.cluster.node_stats :indices => true, :metric => 'fielddata', :fields => 'foo,bar'
58
- subject.cluster.node_stats :indices => true, :metric => 'fielddata', :fields => ['foo','bar']
57
+ subject.nodes.stats :metric => 'indices', :index_metric => 'fielddata', :fields => 'foo,bar'
58
+ subject.nodes.stats :metric => 'indices', :index_metric => 'fielddata', :fields => ['foo','bar']
59
59
  end
60
60
 
61
61
  end
@@ -13,20 +13,9 @@ module Elasticsearch
13
13
  end
14
14
  end
15
15
 
16
- should "require the :body argument" do
16
+ should "require the :type argument" do
17
17
  assert_raise ArgumentError do
18
- subject.percolate :index => 'bar'
19
- end
20
- end
21
-
22
- should "have default document type" do
23
- assert_nothing_raised do
24
- subject.expects(:perform_request).with do |method, url, params, body|
25
- assert_equal 'foo/document/_percolate', url
26
- true
27
- end.returns(FakeResponse.new)
28
-
29
- subject.percolate :index => 'foo', :body => {}
18
+ subject.percolate :index => 'bar', :body => {}
30
19
  end
31
20
  end
32
21
 
@@ -0,0 +1,38 @@
1
+ require 'test_helper'
2
+
3
+ module Elasticsearch
4
+ module Test
5
+ class SnapshotCreateRepositoryTest < ::Test::Unit::TestCase
6
+
7
+ context "Snapshot: Create repository" do
8
+ subject { FakeClient.new }
9
+
10
+ should "require the :repository argument" do
11
+ assert_raise ArgumentError do
12
+ subject.snapshot.create_repository :body => {}
13
+ end
14
+ end
15
+
16
+ should "require the :body argument" do
17
+ assert_raise ArgumentError do
18
+ subject.snapshot.create_repository :repository => 'foo'
19
+ end
20
+ end
21
+
22
+ should "perform correct request" do
23
+ subject.expects(:perform_request).with do |method, url, params, body|
24
+ assert_equal 'PUT', method
25
+ assert_equal '_snapshot/foo', url
26
+ assert_equal Hash.new, params
27
+ assert_equal Hash.new, body
28
+ true
29
+ end.returns(FakeResponse.new)
30
+
31
+ subject.snapshot.create_repository :repository => 'foo', :body => {}
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,38 @@
1
+ require 'test_helper'
2
+
3
+ module Elasticsearch
4
+ module Test
5
+ class SnapshotCreateTest < ::Test::Unit::TestCase
6
+
7
+ context "Snapshot: Create" do
8
+ subject { FakeClient.new }
9
+
10
+ should "require the :repository argument" do
11
+ assert_raise ArgumentError do
12
+ subject.snapshot.create :snapshot => 'bar', :body => {}
13
+ end
14
+ end
15
+
16
+ should "require the :snapshot argument" do
17
+ assert_raise ArgumentError do
18
+ subject.snapshot.create :repository => 'foo', :body => {}
19
+ end
20
+ end
21
+
22
+ should "perform correct request" do
23
+ subject.expects(:perform_request).with do |method, url, params, body|
24
+ assert_equal 'PUT', method
25
+ assert_equal '_snapshot/foo/bar', url
26
+ assert_equal Hash.new, params
27
+ assert_equal Hash.new, body
28
+ true
29
+ end.returns(FakeResponse.new)
30
+
31
+ subject.snapshot.create :repository => 'foo', :snapshot => 'bar', :body => {}
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,35 @@
1
+ require 'test_helper'
2
+
3
+ module Elasticsearch
4
+ module Test
5
+ class SnapshotDeleteRepositoryTest < ::Test::Unit::TestCase
6
+
7
+ context "Snapshot: Delete repository" 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 'DELETE', method
13
+ assert_equal '_snapshot/foo', url
14
+ assert_equal Hash.new, params
15
+ assert_nil body
16
+ true
17
+ end.returns(FakeResponse.new)
18
+
19
+ subject.snapshot.delete_repository :repository => 'foo'
20
+ end
21
+
22
+ should "perform the request for more indices" do
23
+ subject.expects(:perform_request).with do |method, url, params, body|
24
+ assert_equal '_snapshot/foo,bar', url
25
+ true
26
+ end.returns(FakeResponse.new)
27
+
28
+ subject.snapshot.delete_repository :repository => ['foo','bar']
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,38 @@
1
+ require 'test_helper'
2
+
3
+ module Elasticsearch
4
+ module Test
5
+ class SnapshotDeleteTest < ::Test::Unit::TestCase
6
+
7
+ context "Snapshot: Delete" do
8
+ subject { FakeClient.new }
9
+
10
+ should "require the :repository argument" do
11
+ assert_raise ArgumentError do
12
+ subject.snapshot.delete :snapshot => 'bar', :body => {}
13
+ end
14
+ end
15
+
16
+ should "require the :snapshot argument" do
17
+ assert_raise ArgumentError do
18
+ subject.snapshot.delete :repository => 'foo', :body => {}
19
+ end
20
+ end
21
+
22
+ should "perform correct request" do
23
+ subject.expects(:perform_request).with do |method, url, params, body|
24
+ assert_equal 'DELETE', method
25
+ assert_equal '_snapshot/foo/bar', url
26
+ assert_equal Hash.new, params
27
+ assert_nil body
28
+ true
29
+ end.returns(FakeResponse.new)
30
+
31
+ subject.snapshot.delete :repository => 'foo', :snapshot => 'bar'
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+ module Elasticsearch
4
+ module Test
5
+ class SnapshotGetRepositoryTest < ::Test::Unit::TestCase
6
+
7
+ context "Snapshot: Get repository" 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 '_snapshot/foo', url
14
+ assert_equal Hash.new, params
15
+ assert_nil body
16
+ true
17
+ end.returns(FakeResponse.new)
18
+
19
+ subject.snapshot.get_repository :repository => 'foo'
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,38 @@
1
+ require 'test_helper'
2
+
3
+ module Elasticsearch
4
+ module Test
5
+ class SnapshotGetTest < ::Test::Unit::TestCase
6
+
7
+ context "Snapshot: Get" do
8
+ subject { FakeClient.new }
9
+
10
+ should "require the :repository argument" do
11
+ assert_raise ArgumentError do
12
+ subject.snapshot.get :snapshot => 'bar', :body => {}
13
+ end
14
+ end
15
+
16
+ should "require the :snapshot argument" do
17
+ assert_raise ArgumentError do
18
+ subject.snapshot.get :repository => 'foo', :body => {}
19
+ end
20
+ end
21
+
22
+ should "perform correct request" do
23
+ subject.expects(:perform_request).with do |method, url, params, body|
24
+ assert_equal 'GET', method
25
+ assert_equal '_snapshot/foo/bar', url
26
+ assert_equal Hash.new, params
27
+ assert_nil body
28
+ true
29
+ end.returns(FakeResponse.new)
30
+
31
+ subject.snapshot.get :repository => 'foo', :snapshot => 'bar'
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,38 @@
1
+ require 'test_helper'
2
+
3
+ module Elasticsearch
4
+ module Test
5
+ class SnapshotRestoreTest < ::Test::Unit::TestCase
6
+
7
+ context "Snapshot: Restore" do
8
+ subject { FakeClient.new }
9
+
10
+ should "require the :repository argument" do
11
+ assert_raise ArgumentError do
12
+ subject.snapshot.restore :snapshot => 'bar'
13
+ end
14
+ end
15
+
16
+ should "require the :snapshot argument" do
17
+ assert_raise ArgumentError do
18
+ subject.snapshot.restore :repository => 'foo'
19
+ end
20
+ end
21
+
22
+ should "perform correct request" do
23
+ subject.expects(:perform_request).with do |method, url, params, body|
24
+ assert_equal 'POST', method
25
+ assert_equal '_snapshot/foo/bar/_restore', url
26
+ assert_equal Hash.new, params
27
+ assert_equal nil, body
28
+ true
29
+ end.returns(FakeResponse.new)
30
+
31
+ subject.snapshot.restore :repository => 'foo', :snapshot => 'bar'
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+ end
38
+ end