elasticsearch-api 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -2
- data/Rakefile +15 -1
- data/elasticsearch-api.gemspec +12 -0
- data/lib/{elasticsearch-api → elasticsearch-api.rb} +0 -0
- data/lib/elasticsearch/api.rb +9 -0
- data/lib/elasticsearch/api/actions/bulk.rb +9 -9
- data/lib/elasticsearch/api/actions/cluster/health.rb +12 -12
- data/lib/elasticsearch/api/actions/cluster/node_hot_threads.rb +9 -9
- data/lib/elasticsearch/api/actions/cluster/node_info.rb +16 -16
- data/lib/elasticsearch/api/actions/cluster/node_shutdown.rb +7 -7
- data/lib/elasticsearch/api/actions/cluster/node_stats.rb +16 -18
- data/lib/elasticsearch/api/actions/cluster/reroute.rb +4 -6
- data/lib/elasticsearch/api/actions/cluster/state.rb +12 -12
- data/lib/elasticsearch/api/actions/count.rb +9 -9
- data/lib/elasticsearch/api/actions/delete.rb +16 -13
- data/lib/elasticsearch/api/actions/delete_by_query.rb +15 -14
- data/lib/elasticsearch/api/actions/exists.rb +13 -11
- data/lib/elasticsearch/api/actions/explain.rb +28 -17
- data/lib/elasticsearch/api/actions/get.rb +20 -11
- data/lib/elasticsearch/api/actions/get_source.rb +23 -11
- data/lib/elasticsearch/api/actions/index.rb +20 -18
- data/lib/elasticsearch/api/actions/indices/analyze.rb +12 -13
- data/lib/elasticsearch/api/actions/indices/clear_cache.rb +15 -15
- data/lib/elasticsearch/api/actions/indices/close.rb +5 -6
- data/lib/elasticsearch/api/actions/indices/create.rb +5 -6
- data/lib/elasticsearch/api/actions/indices/delete.rb +5 -6
- data/lib/elasticsearch/api/actions/indices/delete_alias.rb +5 -6
- data/lib/elasticsearch/api/actions/indices/delete_mapping.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/delete_template.rb +5 -6
- data/lib/elasticsearch/api/actions/indices/delete_warmer.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/exists_alias.rb +5 -6
- data/lib/elasticsearch/api/actions/indices/exists_type.rb +5 -6
- data/lib/elasticsearch/api/actions/indices/flush.rb +9 -9
- data/lib/elasticsearch/api/actions/indices/get_alias.rb +5 -6
- data/lib/elasticsearch/api/actions/indices/get_aliases.rb +5 -6
- data/lib/elasticsearch/api/actions/indices/get_mapping.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/get_settings.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/get_template.rb +1 -2
- data/lib/elasticsearch/api/actions/indices/get_warmer.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/open.rb +5 -6
- data/lib/elasticsearch/api/actions/indices/optimize.rb +12 -12
- data/lib/elasticsearch/api/actions/indices/put_alias.rb +5 -6
- data/lib/elasticsearch/api/actions/indices/put_mapping.rb +5 -7
- data/lib/elasticsearch/api/actions/indices/put_settings.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/put_template.rb +5 -7
- data/lib/elasticsearch/api/actions/indices/refresh.rb +5 -6
- data/lib/elasticsearch/api/actions/indices/segments.rb +5 -6
- data/lib/elasticsearch/api/actions/indices/snapshot_index.rb +5 -6
- data/lib/elasticsearch/api/actions/indices/stats.rb +23 -23
- data/lib/elasticsearch/api/actions/indices/status.rb +8 -8
- data/lib/elasticsearch/api/actions/indices/update_aliases.rb +4 -5
- data/lib/elasticsearch/api/actions/indices/validate_query.rb +11 -9
- data/lib/elasticsearch/api/actions/mget.rb +21 -11
- data/lib/elasticsearch/api/actions/mlt.rb +28 -24
- data/lib/elasticsearch/api/actions/msearch.rb +4 -5
- data/lib/elasticsearch/api/actions/percolate.rb +7 -6
- data/lib/elasticsearch/api/actions/scroll.rb +5 -6
- data/lib/elasticsearch/api/actions/search.rb +37 -30
- data/lib/elasticsearch/api/actions/suggest.rb +8 -8
- data/lib/elasticsearch/api/actions/update.rb +24 -20
- data/lib/elasticsearch/api/utils.rb +44 -6
- data/lib/elasticsearch/api/version.rb +1 -1
- data/test/integration/yaml_test_runner.rb +4 -5
- data/test/test_helper.rb +1 -1
- data/test/unit/bulk_test.rb +9 -0
- data/test/unit/cluster/node_hot_threads_test.rb +9 -0
- data/test/unit/create_document_test.rb +9 -0
- data/test/unit/delete_document_test.rb +16 -1
- data/test/unit/exists_document_test.rb +9 -0
- data/test/unit/explain_document_test.rb +9 -0
- data/test/unit/get_document_source_test.rb +10 -1
- data/test/unit/get_document_test.rb +16 -1
- data/test/unit/index_document_test.rb +15 -0
- data/test/unit/indices/analyze_test.rb +9 -0
- data/test/unit/indices/clear_cache_test.rb +9 -0
- data/test/unit/indices/close_test.rb +9 -0
- data/test/unit/indices/create_test.rb +9 -0
- data/test/unit/indices/delete_alias_test.rb +9 -0
- data/test/unit/indices/delete_mapping_test.rb +9 -0
- data/test/unit/indices/delete_template_test.rb +9 -0
- data/test/unit/indices/delete_test.rb +9 -0
- data/test/unit/indices/delete_warmer_test.rb +9 -0
- data/test/unit/indices/exists_alias_test.rb +9 -0
- data/test/unit/indices/exists_test.rb +9 -0
- data/test/unit/indices/exists_type_test.rb +9 -0
- data/test/unit/indices/flush_test.rb +9 -0
- data/test/unit/indices/get_alias_test.rb +9 -0
- data/test/unit/indices/get_aliases_test.rb +9 -0
- data/test/unit/indices/get_mapping_test.rb +9 -0
- data/test/unit/indices/get_settings_test.rb +9 -0
- data/test/unit/indices/get_template_test.rb +10 -6
- data/test/unit/indices/get_warmer_test.rb +9 -0
- data/test/unit/indices/open_test.rb +9 -0
- data/test/unit/indices/optimize_test.rb +9 -0
- data/test/unit/indices/put_alias_test.rb +9 -0
- data/test/unit/indices/put_mapping_test.rb +9 -0
- data/test/unit/indices/put_settings_test.rb +9 -0
- data/test/unit/indices/put_template_test.rb +9 -0
- data/test/unit/indices/put_warmer_test.rb +9 -0
- data/test/unit/indices/refresh_test.rb +9 -0
- data/test/unit/indices/segments_test.rb +9 -0
- data/test/unit/indices/snapshot_index_test.rb +9 -0
- data/test/unit/indices/stats_test.rb +9 -0
- data/test/unit/indices/status_test.rb +9 -0
- data/test/unit/indices/validate_query_test.rb +9 -0
- data/test/unit/mget_test.rb +9 -0
- data/test/unit/mlt_test.rb +9 -0
- data/test/unit/msearch_test.rb +9 -0
- data/test/unit/percolate_test.rb +9 -0
- data/test/unit/search_test.rb +16 -1
- data/test/unit/suggest_test.rb +9 -0
- data/test/unit/update_document_test.rb +16 -1
- data/test/unit/utils_test.rb +34 -5
- metadata +161 -44
- checksums.yaml +0 -7
@@ -28,6 +28,15 @@ module Elasticsearch
|
|
28
28
|
subject.indices.flush :index => ['foo','bar']
|
29
29
|
end
|
30
30
|
|
31
|
+
should "URL-escape the parts" do
|
32
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
33
|
+
assert_equal 'foo%5Ebar/_flush', url
|
34
|
+
true
|
35
|
+
end.returns(FakeResponse.new)
|
36
|
+
|
37
|
+
subject.indices.flush :index => 'foo^bar'
|
38
|
+
end
|
39
|
+
|
31
40
|
should "pass the URL parameters" do
|
32
41
|
subject.expects(:perform_request).with do |method, url, params, body|
|
33
42
|
assert_equal 'foo/_flush', url
|
@@ -34,6 +34,15 @@ module Elasticsearch
|
|
34
34
|
subject.indices.get_alias :index => ['foo','bar'], :name => 'bam'
|
35
35
|
end
|
36
36
|
|
37
|
+
should "URL-escape the parts" do
|
38
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
39
|
+
assert_equal 'foo%5Ebar/_alias/bar%2Fbam', url
|
40
|
+
true
|
41
|
+
end.returns(FakeResponse.new)
|
42
|
+
|
43
|
+
subject.indices.get_alias :index => 'foo^bar', :name => 'bar/bam'
|
44
|
+
end
|
45
|
+
|
37
46
|
end
|
38
47
|
|
39
48
|
end
|
@@ -28,6 +28,15 @@ module Elasticsearch
|
|
28
28
|
subject.indices.get_aliases :index => 'foo'
|
29
29
|
end
|
30
30
|
|
31
|
+
should "URL-escape the parts" do
|
32
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
33
|
+
assert_equal 'foo%5Ebar/_aliases', url
|
34
|
+
true
|
35
|
+
end.returns(FakeResponse.new)
|
36
|
+
|
37
|
+
subject.indices.get_aliases :index => 'foo^bar'
|
38
|
+
end
|
39
|
+
|
31
40
|
end
|
32
41
|
|
33
42
|
end
|
@@ -46,6 +46,15 @@ module Elasticsearch
|
|
46
46
|
subject.indices.get_mapping :index => ['foo', 'bar'], :type => ['bam', 'baz']
|
47
47
|
end
|
48
48
|
|
49
|
+
should "URL-escape the parts" do
|
50
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
51
|
+
assert_equal 'foo%5Ebar/bar%2Fbam/_mapping', url
|
52
|
+
true
|
53
|
+
end.returns(FakeResponse.new)
|
54
|
+
|
55
|
+
subject.indices.get_mapping :index => 'foo^bar', :type => 'bar/bam'
|
56
|
+
end
|
57
|
+
|
49
58
|
end
|
50
59
|
|
51
60
|
end
|
@@ -28,6 +28,15 @@ module Elasticsearch
|
|
28
28
|
subject.indices.get_settings :index => 'foo'
|
29
29
|
end
|
30
30
|
|
31
|
+
should "URL-escape the parts" do
|
32
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
33
|
+
assert_equal 'foo%5Ebar/_settings', url
|
34
|
+
true
|
35
|
+
end.returns(FakeResponse.new)
|
36
|
+
|
37
|
+
subject.indices.get_settings :index => 'foo^bar'
|
38
|
+
end
|
39
|
+
|
31
40
|
end
|
32
41
|
|
33
42
|
end
|
@@ -7,12 +7,6 @@ module Elasticsearch
|
|
7
7
|
context "Indices: Get template" do
|
8
8
|
subject { FakeClient.new }
|
9
9
|
|
10
|
-
should "require the :name argument" do
|
11
|
-
assert_raise ArgumentError do
|
12
|
-
subject.indices.get_template
|
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
|
@@ -25,6 +19,16 @@ module Elasticsearch
|
|
25
19
|
subject.indices.get_template :name => 'foo'
|
26
20
|
end
|
27
21
|
|
22
|
+
should "URL-escape the parts" do
|
23
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
24
|
+
assert_equal '_template/foo%5Ebar', url
|
25
|
+
true
|
26
|
+
end.returns(FakeResponse.new)
|
27
|
+
|
28
|
+
subject.indices.get_template :name => 'foo^bar'
|
29
|
+
end
|
30
|
+
|
31
|
+
|
28
32
|
end
|
29
33
|
|
30
34
|
end
|
@@ -34,6 +34,15 @@ module Elasticsearch
|
|
34
34
|
subject.indices.get_warmer :index => 'foo', :name => 'bar'
|
35
35
|
end
|
36
36
|
|
37
|
+
should "URL-escape the parts" do
|
38
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
39
|
+
assert_equal 'foo%5Ebar/_warmer/bar%2Fbam', url
|
40
|
+
true
|
41
|
+
end.returns(FakeResponse.new)
|
42
|
+
|
43
|
+
subject.indices.get_warmer :index => 'foo^bar', :name => 'bar/bam'
|
44
|
+
end
|
45
|
+
|
37
46
|
end
|
38
47
|
|
39
48
|
end
|
@@ -35,6 +35,15 @@ module Elasticsearch
|
|
35
35
|
subject.indices.open :index => 'foo', :timeout => '1s'
|
36
36
|
end
|
37
37
|
|
38
|
+
should "URL-escape the parts" do
|
39
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
40
|
+
assert_equal 'foo%5Ebar/_open', url
|
41
|
+
true
|
42
|
+
end.returns(FakeResponse.new)
|
43
|
+
|
44
|
+
subject.indices.open :index => 'foo^bar'
|
45
|
+
end
|
46
|
+
|
38
47
|
end
|
39
48
|
|
40
49
|
end
|
@@ -38,6 +38,15 @@ module Elasticsearch
|
|
38
38
|
subject.indices.optimize :index => 'foo', :max_num_segments => 1
|
39
39
|
end
|
40
40
|
|
41
|
+
should "URL-escape the parts" do
|
42
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
43
|
+
assert_equal 'foo%5Ebar/_optimize', url
|
44
|
+
true
|
45
|
+
end.returns(FakeResponse.new)
|
46
|
+
|
47
|
+
subject.indices.optimize :index => 'foo^bar'
|
48
|
+
end
|
49
|
+
|
41
50
|
end
|
42
51
|
|
43
52
|
end
|
@@ -40,6 +40,15 @@ module Elasticsearch
|
|
40
40
|
subject.indices.put_alias :index => 'foo', :name => 'bar', :body => { :filter => 'foo' }
|
41
41
|
end
|
42
42
|
|
43
|
+
should "URL-escape the parts" do
|
44
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
45
|
+
assert_equal 'foo%5Ebar/_alias/bar%2Fbam', url
|
46
|
+
true
|
47
|
+
end.returns(FakeResponse.new)
|
48
|
+
|
49
|
+
subject.indices.put_alias :index => 'foo^bar', :name => 'bar/bam', :body => {}
|
50
|
+
end
|
51
|
+
|
43
52
|
end
|
44
53
|
|
45
54
|
end
|
@@ -50,6 +50,15 @@ module Elasticsearch
|
|
50
50
|
subject.indices.put_mapping :index => 'foo', :type => 'bar', :body => {}, :ignore_conflicts => true
|
51
51
|
end
|
52
52
|
|
53
|
+
should "URL-escape the parts" do
|
54
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
55
|
+
assert_equal 'foo%5Ebar/bar%2Fbam/_mapping', url
|
56
|
+
true
|
57
|
+
end.returns(FakeResponse.new)
|
58
|
+
|
59
|
+
subject.indices.put_mapping :index => 'foo^bar', :type => 'bar/bam', :body => {}
|
60
|
+
end
|
61
|
+
|
53
62
|
end
|
54
63
|
|
55
64
|
end
|
@@ -43,6 +43,15 @@ module Elasticsearch
|
|
43
43
|
subject.indices.put_settings :index => ['foo','bar'], :body => {}
|
44
44
|
end
|
45
45
|
|
46
|
+
should "URL-escape the parts" do
|
47
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
48
|
+
assert_equal 'foo%5Ebar/_settings', url
|
49
|
+
true
|
50
|
+
end.returns(FakeResponse.new)
|
51
|
+
|
52
|
+
subject.indices.put_settings :index => 'foo^bar', :body => {}
|
53
|
+
end
|
54
|
+
|
46
55
|
end
|
47
56
|
|
48
57
|
end
|
@@ -41,6 +41,15 @@ module Elasticsearch
|
|
41
41
|
subject.indices.put_template :name => 'foo', :body => {}, :order => 3
|
42
42
|
end
|
43
43
|
|
44
|
+
should "URL-escape the parts" do
|
45
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
46
|
+
assert_equal '_template/foo%5Ebar', url
|
47
|
+
true
|
48
|
+
end.returns(FakeResponse.new)
|
49
|
+
|
50
|
+
subject.indices.put_template :name => 'foo^bar', :body => {}
|
51
|
+
end
|
52
|
+
|
44
53
|
end
|
45
54
|
|
46
55
|
end
|
@@ -55,6 +55,15 @@ module Elasticsearch
|
|
55
55
|
subject.indices.put_warmer :index => 'foo', :type => 'bar', :name => 'xul', :body => {}
|
56
56
|
end
|
57
57
|
|
58
|
+
should "URL-escape the parts" do
|
59
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
60
|
+
assert_equal 'foo%5Ebar/bar%2Fbam/_warmer/qu+uz', url
|
61
|
+
true
|
62
|
+
end.returns(FakeResponse.new)
|
63
|
+
|
64
|
+
subject.indices.put_warmer :index => 'foo^bar', :type => 'bar/bam', :name => 'qu uz', :body => {}
|
65
|
+
end
|
66
|
+
|
58
67
|
end
|
59
68
|
|
60
69
|
end
|
@@ -48,6 +48,15 @@ module Elasticsearch
|
|
48
48
|
subject.indices.refresh :index => ['foo','bar'], :ignore_indices => 'missing'
|
49
49
|
end
|
50
50
|
|
51
|
+
should "URL-escape the parts" do
|
52
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
53
|
+
assert_equal 'foo%5Ebar/_refresh', url
|
54
|
+
true
|
55
|
+
end.returns(FakeResponse.new)
|
56
|
+
|
57
|
+
subject.indices.refresh :index => 'foo^bar'
|
58
|
+
end
|
59
|
+
|
51
60
|
end
|
52
61
|
|
53
62
|
end
|
@@ -48,6 +48,15 @@ module Elasticsearch
|
|
48
48
|
subject.indices.segments :index => ['foo','bar'], :ignore_indices => 'missing'
|
49
49
|
end
|
50
50
|
|
51
|
+
should "URL-escape the parts" do
|
52
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
53
|
+
assert_equal 'foo%5Ebar/_segments', url
|
54
|
+
true
|
55
|
+
end.returns(FakeResponse.new)
|
56
|
+
|
57
|
+
subject.indices.segments :index => 'foo^bar'
|
58
|
+
end
|
59
|
+
|
51
60
|
end
|
52
61
|
|
53
62
|
end
|
@@ -48,6 +48,15 @@ module Elasticsearch
|
|
48
48
|
subject.indices.snapshot_index :index => ['foo','bar'], :ignore_indices => 'missing'
|
49
49
|
end
|
50
50
|
|
51
|
+
should "URL-escape the parts" do
|
52
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
53
|
+
assert_equal 'foo%5Ebar/_gateway/snapshot', url
|
54
|
+
true
|
55
|
+
end.returns(FakeResponse.new)
|
56
|
+
|
57
|
+
subject.indices.snapshot_index :index => 'foo^bar'
|
58
|
+
end
|
59
|
+
|
51
60
|
end
|
52
61
|
|
53
62
|
end
|
@@ -48,6 +48,15 @@ module Elasticsearch
|
|
48
48
|
subject.indices.stats :index => 'foo', :fielddata => true
|
49
49
|
end
|
50
50
|
|
51
|
+
should "URL-escape the parts" do
|
52
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
53
|
+
assert_equal 'foo%5Ebar/_stats', url
|
54
|
+
true
|
55
|
+
end.returns(FakeResponse.new)
|
56
|
+
|
57
|
+
subject.indices.stats :index => 'foo^bar'
|
58
|
+
end
|
59
|
+
|
51
60
|
should "pass the fields parameter as a list" do
|
52
61
|
subject.expects(:perform_request).with do |method, url, params, body|
|
53
62
|
assert_equal 'foo/_stats', url
|
@@ -48,6 +48,15 @@ module Elasticsearch
|
|
48
48
|
subject.indices.status :index => 'foo', :recovery => true
|
49
49
|
end
|
50
50
|
|
51
|
+
should "URL-escape the parts" do
|
52
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
53
|
+
assert_equal 'foo%5Ebar/_status', url
|
54
|
+
true
|
55
|
+
end.returns(FakeResponse.new)
|
56
|
+
|
57
|
+
subject.indices.status :index => 'foo^bar'
|
58
|
+
end
|
59
|
+
|
51
60
|
end
|
52
61
|
|
53
62
|
end
|
@@ -68,6 +68,15 @@ module Elasticsearch
|
|
68
68
|
subject.indices.validate_query :body => { :filtered => {} }
|
69
69
|
end
|
70
70
|
|
71
|
+
should "URL-escape the parts" do
|
72
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
73
|
+
assert_equal 'foo%5Ebar/_validate/query', url
|
74
|
+
true
|
75
|
+
end.returns(FakeResponse.new)
|
76
|
+
|
77
|
+
subject.indices.validate_query :index => 'foo^bar', :body => {}
|
78
|
+
end
|
79
|
+
|
71
80
|
end
|
72
81
|
|
73
82
|
end
|
data/test/unit/mget_test.rb
CHANGED
@@ -54,6 +54,15 @@ module Elasticsearch
|
|
54
54
|
subject.mget :body => {}, :refresh => true
|
55
55
|
end
|
56
56
|
|
57
|
+
should "URL-escape the parts" do
|
58
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
59
|
+
assert_equal 'foo%5Ebar/bar%2Fbam/_mget', url
|
60
|
+
true
|
61
|
+
end.returns(FakeResponse.new)
|
62
|
+
|
63
|
+
subject.mget :index => 'foo^bar', :type => 'bar/bam', :body => { :ids => ['1','2'] }
|
64
|
+
end
|
65
|
+
|
57
66
|
should "pass the fields parameter as a list" do
|
58
67
|
subject.expects(:perform_request).with do |method, url, params, body|
|
59
68
|
assert_equal 'foo,bar', params[:fields]
|
data/test/unit/mlt_test.rb
CHANGED
@@ -47,6 +47,15 @@ module Elasticsearch
|
|
47
47
|
subject.mlt :index => 'foo', :type => 'bar', :id => '1', :max_doc_freq => 1
|
48
48
|
end
|
49
49
|
|
50
|
+
should "URL-escape the parts" do
|
51
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
52
|
+
assert_equal 'foo%5Ebar/bar%2Fbam/1/_mlt', url
|
53
|
+
true
|
54
|
+
end.returns(FakeResponse.new)
|
55
|
+
|
56
|
+
subject.mlt :index => 'foo^bar', :type => 'bar/bam', :id => '1'
|
57
|
+
end
|
58
|
+
|
50
59
|
should "pass the specific parameters as a list" do
|
51
60
|
subject.expects(:perform_request).with do |method, url, params, body|
|
52
61
|
assert_equal 'foo,bar', params[:mlt_fields]
|
data/test/unit/msearch_test.rb
CHANGED
@@ -103,6 +103,15 @@ module Elasticsearch
|
|
103
103
|
subject.msearch :index => ['foo', 'bar'], :type => ['lam', 'bam'], :body => []
|
104
104
|
end
|
105
105
|
|
106
|
+
should "URL-escape the parts" do
|
107
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
108
|
+
assert_equal 'foo%5Ebar/bar%2Fbam/_msearch', url
|
109
|
+
true
|
110
|
+
end.returns(FakeResponse.new)
|
111
|
+
|
112
|
+
subject.msearch :index => 'foo^bar', :type => 'bar/bam', :body => []
|
113
|
+
end
|
114
|
+
|
106
115
|
should "encode URL parameters" do
|
107
116
|
subject.expects(:perform_request).with do |method, url, params, body|
|
108
117
|
assert_equal '_msearch', url
|
data/test/unit/percolate_test.rb
CHANGED
@@ -42,6 +42,15 @@ module Elasticsearch
|
|
42
42
|
subject.percolate :index => 'foo', :type => 'bar', :body => { :doc => { :foo => 'bar' } }
|
43
43
|
end
|
44
44
|
|
45
|
+
should "URL-escape the parts" do
|
46
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
47
|
+
assert_equal 'foo%5Ebar/bar%2Fbam/_percolate', url
|
48
|
+
true
|
49
|
+
end.returns(FakeResponse.new)
|
50
|
+
|
51
|
+
subject.percolate :index => 'foo^bar', :type => 'bar/bam', :body => { :doc => { :foo => 'bar' } }
|
52
|
+
end
|
53
|
+
|
45
54
|
end
|
46
55
|
|
47
56
|
end
|
data/test/unit/search_test.rb
CHANGED
@@ -26,7 +26,7 @@ module Elasticsearch
|
|
26
26
|
true
|
27
27
|
end.returns(FakeResponse.new)
|
28
28
|
|
29
|
-
subject.search type
|
29
|
+
subject.search :type => 'foo'
|
30
30
|
end
|
31
31
|
|
32
32
|
should "post a request definition in body" do
|
@@ -86,6 +86,21 @@ module Elasticsearch
|
|
86
86
|
subject.search :search_type => 'count'
|
87
87
|
end
|
88
88
|
|
89
|
+
should "validate URL parameters" do
|
90
|
+
assert_raise ArgumentError do
|
91
|
+
subject.search :search_type => 'count', :qwertypoiuy => 'asdflkjhg'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
should "URL-escape the parts" do
|
96
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
97
|
+
assert_equal 'foo%5Ebar/bar%2Fbam/_search', url
|
98
|
+
true
|
99
|
+
end.returns(FakeResponse.new)
|
100
|
+
|
101
|
+
subject.search :index => 'foo^bar', :type => 'bar/bam'
|
102
|
+
end
|
103
|
+
|
89
104
|
end
|
90
105
|
|
91
106
|
end
|