elasticsearch-api 1.0.13 → 1.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/Rakefile +0 -3
- data/lib/elasticsearch/api/actions/bulk.rb +9 -2
- data/lib/elasticsearch/api/actions/cat/nodeattrs.rb +33 -0
- data/lib/elasticsearch/api/actions/field_stats.rb +2 -2
- data/lib/elasticsearch/api/actions/indices/clear_cache.rb +2 -2
- data/lib/elasticsearch/api/actions/indices/exists_type.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/shard_stores.rb +34 -0
- data/lib/elasticsearch/api/actions/indices/status.rb +5 -1
- data/lib/elasticsearch/api/actions/msearch.rb +2 -2
- data/lib/elasticsearch/api/actions/percolate.rb +1 -1
- data/lib/elasticsearch/api/actions/render_search_template.rb +25 -0
- data/lib/elasticsearch/api/actions/search.rb +3 -3
- data/lib/elasticsearch/api/actions/snapshot/delete.rb +6 -1
- data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +6 -1
- data/lib/elasticsearch/api/actions/snapshot/get.rb +6 -1
- data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +6 -1
- data/lib/elasticsearch/api/actions/snapshot/status.rb +6 -1
- data/lib/elasticsearch/api/version.rb +1 -1
- data/test/integration/yaml_test_runner.rb +13 -3
- data/test/unit/bulk_test.rb +10 -0
- data/test/unit/cat/nodeattrs_test.rb +26 -0
- data/test/unit/indices/shard_stores_test.rb +26 -0
- data/test/unit/indices/status_test.rb +8 -0
- data/test/unit/percolate_test.rb +9 -0
- data/test/unit/render_search_template_test.rb +25 -0
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: add02a3828ecb6751a1407bf67948ce6535755c0
|
4
|
+
data.tar.gz: b588139998125833ca9e79e06493ab1b01392af4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1708eb748a72a1a91a3938c9a79cb9ea7551fc9c8c81536d89820fed95fef2f490dab6cda4d1590f7343d8cfdbb947e2f0908318d8a754534856c469c55de3d
|
7
|
+
data.tar.gz: 25ce3999ae3976266497b8ea7e77f7d6592e8538decb800a29a87ab13c5c7bc6747d46ffbf09ad5feac6aa9e8cbcc36cf8928f518318aec90048d360bb572ba9
|
data/README.md
CHANGED
@@ -143,7 +143,7 @@ require 'hashie'
|
|
143
143
|
response = client.search index: 'myindex',
|
144
144
|
body: {
|
145
145
|
query: { match: { title: 'test' } },
|
146
|
-
|
146
|
+
aggregations: { tags: { terms: { field: 'tags' } } }
|
147
147
|
}
|
148
148
|
|
149
149
|
mash = Hashie::Mash.new response
|
@@ -151,7 +151,7 @@ mash = Hashie::Mash.new response
|
|
151
151
|
mash.hits.hits.first._source.title
|
152
152
|
# => 'Test'
|
153
153
|
|
154
|
-
mash.
|
154
|
+
mash.aggregations.tags.terms.first
|
155
155
|
# => #<Hashie::Mash count=3 term="z">
|
156
156
|
```
|
157
157
|
|
data/Rakefile
CHANGED
@@ -97,9 +97,6 @@ namespace :test do
|
|
97
97
|
git_specs "checkout #{checkout_build_hash} --force --quiet"
|
98
98
|
end
|
99
99
|
|
100
|
-
# Path to the API specs
|
101
|
-
ENV['TEST_REST_API_SPEC'] = __current__.join('../tmp/elasticsearch/rest-api-spec/test/').to_s
|
102
|
-
|
103
100
|
# Run the task
|
104
101
|
args = [t.ruby_opts_string, t.run_code, t.file_list_string, t.option_list].join(' ')
|
105
102
|
|
@@ -52,21 +52,28 @@ module Elasticsearch
|
|
52
52
|
# @option arguments [Boolean] :refresh Refresh the index after performing the operation
|
53
53
|
# @option arguments [String] :replication Explicitly set the replication type (options: sync, async)
|
54
54
|
# @option arguments [Time] :timeout Explicit operation timeout
|
55
|
+
# @option arguments [String] :fields Default comma-separated list of fields to return
|
56
|
+
# in the response for updates
|
55
57
|
#
|
56
58
|
# @return [Hash] Deserialized Elasticsearch response
|
57
59
|
#
|
58
60
|
# @see http://elasticsearch.org/guide/reference/api/bulk/
|
59
61
|
#
|
60
62
|
def bulk(arguments={})
|
63
|
+
arguments = arguments.clone
|
64
|
+
|
65
|
+
type = arguments.delete(:type)
|
66
|
+
|
61
67
|
valid_params = [
|
62
68
|
:consistency,
|
63
69
|
:refresh,
|
64
70
|
:replication,
|
65
71
|
:type,
|
66
|
-
:timeout
|
72
|
+
:timeout,
|
73
|
+
:fields ]
|
67
74
|
|
68
75
|
method = HTTP_POST
|
69
|
-
path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(
|
76
|
+
path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(type), '_bulk'
|
70
77
|
|
71
78
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
72
79
|
body = arguments[:body]
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Cat
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Display custom node attributes
|
7
|
+
#
|
8
|
+
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false)
|
9
|
+
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
|
10
|
+
# @option arguments [List] :h Comma-separated list of column names to display
|
11
|
+
# @option arguments [Boolean] :help Return help information
|
12
|
+
# @option arguments [Boolean] :v Verbose mode. Display column headers
|
13
|
+
#
|
14
|
+
# @see http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html
|
15
|
+
#
|
16
|
+
def nodeattrs(arguments={})
|
17
|
+
valid_params = [
|
18
|
+
:local,
|
19
|
+
:master_timeout,
|
20
|
+
:h,
|
21
|
+
:help,
|
22
|
+
:v ]
|
23
|
+
method = 'GET'
|
24
|
+
path = "_cat/nodeattrs"
|
25
|
+
params = Utils.__validate_and_extract_params arguments, valid_params
|
26
|
+
body = nil
|
27
|
+
|
28
|
+
perform_request(method, path, params, body).body
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -21,9 +21,9 @@ module Elasticsearch
|
|
21
21
|
:allow_no_indices,
|
22
22
|
:expand_wildcards ]
|
23
23
|
method = 'GET'
|
24
|
-
path = "_field_stats"
|
24
|
+
path = Utils.__pathify Utils.__escape(arguments[:index]), "_field_stats"
|
25
25
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
26
|
-
body =
|
26
|
+
body = arguments[:body]
|
27
27
|
|
28
28
|
perform_request(method, path, params, body).body
|
29
29
|
end
|
@@ -34,7 +34,7 @@ module Elasticsearch
|
|
34
34
|
# `field_data` parameter(default: all)
|
35
35
|
# @option arguments [Boolean] :filter Clear filter caches
|
36
36
|
# @option arguments [Boolean] :filter_cache Clear filter caches
|
37
|
-
# @option arguments [
|
37
|
+
# @option arguments [List] :filter_keys A comma-separated list of keys to clear when using the
|
38
38
|
# `filter_cache` parameter (default: all)
|
39
39
|
# @option arguments [Boolean] :id Clear ID caches for parent/child
|
40
40
|
# @option arguments [Boolean] :id_cache Clear ID caches for parent/child
|
@@ -45,7 +45,7 @@ module Elasticsearch
|
|
45
45
|
# @option arguments [List] :index A comma-separated list of index name to limit the operation
|
46
46
|
# @option arguments [Boolean] :recycler Clear the recycler cache
|
47
47
|
#
|
48
|
-
# @see
|
48
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clearcache.html
|
49
49
|
#
|
50
50
|
def clear_cache(arguments={})
|
51
51
|
valid_params = [
|
@@ -5,7 +5,7 @@ module Elasticsearch
|
|
5
5
|
|
6
6
|
# Return true if the specified type exists, false otherwise.
|
7
7
|
#
|
8
|
-
# client.indices.exists_type? type: 'mytype'
|
8
|
+
# client.indices.exists_type? index: 'myindex', type: 'mytype'
|
9
9
|
#
|
10
10
|
# @option arguments [List] :index A comma-separated list of index names; use `_all`
|
11
11
|
# to check the types across all indices (*Required*)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Indices
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Provides low-level information about shards (allocated nodes, exceptions, ...)
|
7
|
+
#
|
8
|
+
# @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
|
9
|
+
# @option arguments [List] :status A comma-separated list of statuses used to filter on shards to get store information for (options: green, yellow, red, all)
|
10
|
+
# @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
11
|
+
# @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
|
12
|
+
# @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, none, all)
|
13
|
+
# @option arguments [String] :operation_threading
|
14
|
+
#
|
15
|
+
# @see http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shards-stores.html
|
16
|
+
#
|
17
|
+
def shard_stores(arguments={})
|
18
|
+
valid_params = [
|
19
|
+
:status,
|
20
|
+
:ignore_unavailable,
|
21
|
+
:allow_no_indices,
|
22
|
+
:expand_wildcards,
|
23
|
+
:operation_threading ]
|
24
|
+
method = 'GET'
|
25
|
+
path = Utils.__pathify Utils.__escape(arguments[:index]), "_shard_stores"
|
26
|
+
params = Utils.__validate_and_extract_params arguments, valid_params
|
27
|
+
body = nil
|
28
|
+
|
29
|
+
perform_request(method, path, params, body).body
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -48,7 +48,11 @@ module Elasticsearch
|
|
48
48
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
49
49
|
body = nil
|
50
50
|
|
51
|
-
|
51
|
+
if Array(arguments[:ignore]).include?(404)
|
52
|
+
Utils.__rescue_from_not_found { perform_request(method, path, params, body).body }
|
53
|
+
else
|
54
|
+
perform_request(method, path, params, body).body
|
55
|
+
end
|
52
56
|
end
|
53
57
|
end
|
54
58
|
end
|
@@ -12,7 +12,7 @@ module Elasticsearch
|
|
12
12
|
# body: [
|
13
13
|
# { search: { query: { match_all: {} } } },
|
14
14
|
# { index: 'myindex', type: 'mytype', search: { query: { query_string: { query: '"Test 1"' } } } },
|
15
|
-
# { search_type: 'count', search: {
|
15
|
+
# { search_type: 'count', search: { aggregations: { published: { terms: { field: 'published' } } } } }
|
16
16
|
# ]
|
17
17
|
#
|
18
18
|
# @example Perform multiple different searches as an array of meta/data pairs
|
@@ -23,7 +23,7 @@ module Elasticsearch
|
|
23
23
|
# { index: 'myindex', type: 'mytype' },
|
24
24
|
# { query: { query_string: { query: '"Test 1"' } } },
|
25
25
|
# { search_type: 'count' },
|
26
|
-
# {
|
26
|
+
# { aggregations: { published: { terms: { field: 'published' } } } }
|
27
27
|
# ]
|
28
28
|
#
|
29
29
|
# @option arguments [List] :index A comma-separated list of index names to use as default
|
@@ -93,7 +93,7 @@ module Elasticsearch
|
|
93
93
|
method = HTTP_GET
|
94
94
|
path = Utils.__pathify Utils.__escape(arguments[:index]),
|
95
95
|
Utils.__escape(arguments[:type]),
|
96
|
-
arguments[:id],
|
96
|
+
Utils.__escape(arguments[:id]),
|
97
97
|
'_percolate'
|
98
98
|
|
99
99
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Actions
|
4
|
+
|
5
|
+
# Pre-render search requests before they are executed and fill existing templates with template parameters
|
6
|
+
#
|
7
|
+
# @option arguments [String] :id The id of the stored search template
|
8
|
+
# @option arguments [Hash] :body The search definition template and its params
|
9
|
+
#
|
10
|
+
# @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-template.html
|
11
|
+
#
|
12
|
+
def render_search_template(arguments={})
|
13
|
+
valid_params = [
|
14
|
+
:id
|
15
|
+
]
|
16
|
+
method = 'GET'
|
17
|
+
path = "_render/template"
|
18
|
+
params = Utils.__validate_and_extract_params arguments, valid_params
|
19
|
+
body = arguments[:body]
|
20
|
+
|
21
|
+
perform_request(method, path, params, body).body
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -19,7 +19,7 @@ module Elasticsearch
|
|
19
19
|
# client.search index: 'myindex',
|
20
20
|
# body: {
|
21
21
|
# query: { match: { title: 'test' } },
|
22
|
-
#
|
22
|
+
# aggregations: { tags: { terms: { field: 'tags' } } }
|
23
23
|
# }
|
24
24
|
#
|
25
25
|
# @example Paginating results: return 10 documents, beginning from the 10th
|
@@ -53,14 +53,14 @@ module Elasticsearch
|
|
53
53
|
# response = client.search index: 'myindex',
|
54
54
|
# body: {
|
55
55
|
# query: { match: { title: 'test' } },
|
56
|
-
#
|
56
|
+
# aggregations: { tags: { terms: { field: 'tags' } } }
|
57
57
|
# }
|
58
58
|
#
|
59
59
|
# response = Hashie::Mash.new response
|
60
60
|
#
|
61
61
|
# response.hits.hits.first._source.title
|
62
62
|
#
|
63
|
-
# response.
|
63
|
+
# response.aggregations.tags.terms.to_a.map { |f| "#{f.term} [#{f.count}]" }.join(', ')
|
64
64
|
#
|
65
65
|
# @option arguments [List] :index A comma-separated list of index names to search; use `_all`
|
66
66
|
# or empty string to perform the operation on all indices
|
@@ -14,6 +14,7 @@ module Elasticsearch
|
|
14
14
|
# @option arguments [String] :repository A repository name (*Required*)
|
15
15
|
# @option arguments [String] :snapshot A snapshot name (*Required*)
|
16
16
|
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
|
17
|
+
# @option arguments [Number,List] :ignore The list of HTTP errors to ignore
|
17
18
|
#
|
18
19
|
# @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
|
19
20
|
#
|
@@ -33,7 +34,11 @@ module Elasticsearch
|
|
33
34
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
34
35
|
body = nil
|
35
36
|
|
36
|
-
|
37
|
+
if Array(arguments[:ignore]).include?(404)
|
38
|
+
Utils.__rescue_from_not_found { perform_request(method, path, params, body).body }
|
39
|
+
else
|
40
|
+
perform_request(method, path, params, body).body
|
41
|
+
end
|
37
42
|
end
|
38
43
|
end
|
39
44
|
end
|
@@ -12,6 +12,7 @@ module Elasticsearch
|
|
12
12
|
# @option arguments [List] :repository A comma-separated list of repository names (*Required*)
|
13
13
|
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
|
14
14
|
# @option arguments [Time] :timeout Explicit operation timeout
|
15
|
+
# @option arguments [Number,List] :ignore The list of HTTP errors to ignore
|
15
16
|
#
|
16
17
|
# @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
|
17
18
|
#
|
@@ -30,7 +31,11 @@ module Elasticsearch
|
|
30
31
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
31
32
|
body = nil
|
32
33
|
|
33
|
-
|
34
|
+
if Array(arguments[:ignore]).include?(404)
|
35
|
+
Utils.__rescue_from_not_found { perform_request(method, path, params, body).body }
|
36
|
+
else
|
37
|
+
perform_request(method, path, params, body).body
|
38
|
+
end
|
34
39
|
end
|
35
40
|
end
|
36
41
|
end
|
@@ -20,6 +20,7 @@ module Elasticsearch
|
|
20
20
|
# @option arguments [String] :repository A repository name (*Required*)
|
21
21
|
# @option arguments [List] :snapshot A comma-separated list of snapshot names (*Required*)
|
22
22
|
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
|
23
|
+
# @option arguments [Number,List] :ignore The list of HTTP errors to ignore
|
23
24
|
#
|
24
25
|
# @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
|
25
26
|
#
|
@@ -39,7 +40,11 @@ module Elasticsearch
|
|
39
40
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
40
41
|
body = nil
|
41
42
|
|
42
|
-
|
43
|
+
if Array(arguments[:ignore]).include?(404)
|
44
|
+
Utils.__rescue_from_not_found { perform_request(method, path, params, body).body }
|
45
|
+
else
|
46
|
+
perform_request(method, path, params, body).body
|
47
|
+
end
|
43
48
|
end
|
44
49
|
end
|
45
50
|
end
|
@@ -18,6 +18,7 @@ module Elasticsearch
|
|
18
18
|
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
|
19
19
|
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
|
20
20
|
# (default: false)
|
21
|
+
# @option arguments [Number,List] :ignore The list of HTTP errors to ignore
|
21
22
|
#
|
22
23
|
# @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
|
23
24
|
#
|
@@ -34,7 +35,11 @@ module Elasticsearch
|
|
34
35
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
35
36
|
body = nil
|
36
37
|
|
37
|
-
|
38
|
+
if Array(arguments[:ignore]).include?(404)
|
39
|
+
Utils.__rescue_from_not_found { perform_request(method, path, params, body).body }
|
40
|
+
else
|
41
|
+
perform_request(method, path, params, body).body
|
42
|
+
end
|
38
43
|
end
|
39
44
|
end
|
40
45
|
end
|
@@ -16,6 +16,7 @@ module Elasticsearch
|
|
16
16
|
# @option arguments [String] :repository A repository name
|
17
17
|
# @option arguments [List] :snapshot A comma-separated list of snapshot names
|
18
18
|
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
|
19
|
+
# @option arguments [Number,List] :ignore The list of HTTP errors to ignore
|
19
20
|
#
|
20
21
|
# @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html#_snapshot_status
|
21
22
|
#
|
@@ -32,7 +33,11 @@ module Elasticsearch
|
|
32
33
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
33
34
|
body = nil
|
34
35
|
|
35
|
-
|
36
|
+
if Array(arguments[:ignore]).include?(404)
|
37
|
+
Utils.__rescue_from_not_found { perform_request(method, path, params, body).body }
|
38
|
+
else
|
39
|
+
perform_request(method, path, params, body).body
|
40
|
+
end
|
36
41
|
end
|
37
42
|
end
|
38
43
|
end
|
@@ -24,7 +24,8 @@ Turn.config.format = :pretty
|
|
24
24
|
# Launch test cluster
|
25
25
|
#
|
26
26
|
if ENV['SERVER'] and not Elasticsearch::Extensions::Test::Cluster.running?
|
27
|
-
|
27
|
+
es_params = "-D es.repositories.url.allowed_urls=http://snapshot.test* -D es.path.repo=/tmp -D es.node.testattr=test " + ENV['TEST_CLUSTER_PARAMS']
|
28
|
+
Elasticsearch::Extensions::Test::Cluster.start(nodes: 1, es_params: es_params )
|
28
29
|
end
|
29
30
|
|
30
31
|
# Register `at_exit` handler for server shutdown.
|
@@ -274,8 +275,9 @@ end
|
|
274
275
|
|
275
276
|
include Elasticsearch::YamlTestSuite
|
276
277
|
|
277
|
-
|
278
|
-
|
278
|
+
rest_api_test_source = $client.info['version']['number'] < '2' ? '../../../../tmp/elasticsearch/rest-api-spec/test' : '../../../../tmp/elasticsearch/rest-api-spec/src/main/resources/rest-api-spec/test'
|
279
|
+
PATH = Pathname(ENV.fetch('TEST_REST_API_SPEC', File.expand_path(rest_api_test_source, __FILE__)))
|
280
|
+
|
279
281
|
suites = Dir.glob(PATH.join('*')).map { |d| Pathname(d) }
|
280
282
|
suites = suites.select { |s| s.to_s =~ Regexp.new(ENV['FILTER']) } if ENV['FILTER']
|
281
283
|
|
@@ -289,6 +291,14 @@ suites.each do |suite|
|
|
289
291
|
setup do
|
290
292
|
$client.indices.delete index: '_all'
|
291
293
|
$client.indices.delete_template name: '*'
|
294
|
+
$client.snapshot.delete repository: 'test_repo_create_1', snapshot: 'test_snapshot', ignore: 404
|
295
|
+
$client.snapshot.delete repository: 'test_repo_restore_1', snapshot: 'test_snapshot', ignore: 404
|
296
|
+
$client.snapshot.delete_repository repository: 'test_repo_create_1', ignore: 404
|
297
|
+
$client.snapshot.delete_repository repository: 'test_repo_restore_1', ignore: 404
|
298
|
+
# FIXME: This shouldn't be needed -------------
|
299
|
+
FileUtils.rm_rf('/tmp/test_repo_create_1_loc')
|
300
|
+
FileUtils.rm_rf('/tmp/test_repo_restore_1_loc')
|
301
|
+
# ---------------------------------------------
|
292
302
|
$results = {}
|
293
303
|
$stash = {}
|
294
304
|
end
|
data/test/unit/bulk_test.rb
CHANGED
@@ -87,6 +87,16 @@ module Elasticsearch
|
|
87
87
|
subject.bulk :index => 'foo^bar', :body => []
|
88
88
|
end
|
89
89
|
|
90
|
+
should "not duplicate the type" do
|
91
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
92
|
+
assert_equal 'myindex/mytype/_bulk', url
|
93
|
+
assert_empty params
|
94
|
+
true
|
95
|
+
end.returns(FakeResponse.new)
|
96
|
+
|
97
|
+
subject.bulk :index => 'myindex', :type => 'mytype', :body => []
|
98
|
+
end
|
99
|
+
|
90
100
|
end
|
91
101
|
|
92
102
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class CatNodeattrsTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Cat: Nodeattrs" 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/nodeattrs', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_nil body
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.cat.nodeattrs
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class IndicesShardStoresTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Indices: Shard stores" 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 '_shard_stores', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_nil body
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.indices.shard_stores
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -57,6 +57,14 @@ module Elasticsearch
|
|
57
57
|
subject.indices.status :index => 'foo^bar'
|
58
58
|
end
|
59
59
|
|
60
|
+
should "catch a NotFound exception with the ignore parameter" do
|
61
|
+
subject.expects(:perform_request).raises(NotFound)
|
62
|
+
|
63
|
+
assert_nothing_raised do
|
64
|
+
subject.indices.status :index => 'foo^bar', :ignore => 404
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
60
68
|
end
|
61
69
|
|
62
70
|
end
|
data/test/unit/percolate_test.rb
CHANGED
@@ -40,6 +40,15 @@ module Elasticsearch
|
|
40
40
|
subject.percolate :index => 'foo^bar', :type => 'bar/bam', :body => { :doc => { :foo => 'bar' } }
|
41
41
|
end
|
42
42
|
|
43
|
+
should "URL-escape the parts (including document id)" do
|
44
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
45
|
+
assert_equal 'foo%5Ebar/bar%2Fbam/some%2Fid/_percolate', url
|
46
|
+
true
|
47
|
+
end.returns(FakeResponse.new)
|
48
|
+
|
49
|
+
subject.percolate :index => 'foo^bar', :type => 'bar/bam', :id => 'some/id'
|
50
|
+
end
|
51
|
+
|
43
52
|
end
|
44
53
|
|
45
54
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class RenderSearchTemplateTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Render search 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 'GET', method
|
13
|
+
assert_equal '_render/template', url
|
14
|
+
assert_equal({ :id => 'foo' }, params)
|
15
|
+
assert_equal({ :foo => 'bar' }, body)
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.render_search_template :id => 'foo', :body => { :foo => 'bar' }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
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: 1.0.
|
4
|
+
version: 1.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karel Minarik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -361,6 +361,7 @@ files:
|
|
361
361
|
- lib/elasticsearch/api/actions/cat/help.rb
|
362
362
|
- lib/elasticsearch/api/actions/cat/indices.rb
|
363
363
|
- lib/elasticsearch/api/actions/cat/master.rb
|
364
|
+
- lib/elasticsearch/api/actions/cat/nodeattrs.rb
|
364
365
|
- lib/elasticsearch/api/actions/cat/nodes.rb
|
365
366
|
- lib/elasticsearch/api/actions/cat/pending_tasks.rb
|
366
367
|
- lib/elasticsearch/api/actions/cat/plugins.rb
|
@@ -424,6 +425,7 @@ files:
|
|
424
425
|
- lib/elasticsearch/api/actions/indices/refresh.rb
|
425
426
|
- lib/elasticsearch/api/actions/indices/seal.rb
|
426
427
|
- lib/elasticsearch/api/actions/indices/segments.rb
|
428
|
+
- lib/elasticsearch/api/actions/indices/shard_stores.rb
|
427
429
|
- lib/elasticsearch/api/actions/indices/snapshot_index.rb
|
428
430
|
- lib/elasticsearch/api/actions/indices/stats.rb
|
429
431
|
- lib/elasticsearch/api/actions/indices/status.rb
|
@@ -445,6 +447,7 @@ files:
|
|
445
447
|
- lib/elasticsearch/api/actions/ping.rb
|
446
448
|
- lib/elasticsearch/api/actions/put_script.rb
|
447
449
|
- lib/elasticsearch/api/actions/put_template.rb
|
450
|
+
- lib/elasticsearch/api/actions/render_search_template.rb
|
448
451
|
- lib/elasticsearch/api/actions/scroll.rb
|
449
452
|
- lib/elasticsearch/api/actions/search.rb
|
450
453
|
- lib/elasticsearch/api/actions/search_exists.rb
|
@@ -484,6 +487,7 @@ files:
|
|
484
487
|
- test/unit/cat/help_test.rb
|
485
488
|
- test/unit/cat/indices_test.rb
|
486
489
|
- test/unit/cat/master_test.rb
|
490
|
+
- test/unit/cat/nodeattrs_test.rb
|
487
491
|
- test/unit/cat/nodes_test.rb
|
488
492
|
- test/unit/cat/pending_tasks_test.rb
|
489
493
|
- test/unit/cat/plugins_test.rb
|
@@ -549,6 +553,7 @@ files:
|
|
549
553
|
- test/unit/indices/refresh_test.rb
|
550
554
|
- test/unit/indices/seal_test.rb
|
551
555
|
- test/unit/indices/segments_test.rb
|
556
|
+
- test/unit/indices/shard_stores_test.rb
|
552
557
|
- test/unit/indices/snapshot_index_test.rb
|
553
558
|
- test/unit/indices/stats_test.rb
|
554
559
|
- test/unit/indices/status_test.rb
|
@@ -571,6 +576,7 @@ files:
|
|
571
576
|
- test/unit/ping_test.rb
|
572
577
|
- test/unit/put_script_test.rb
|
573
578
|
- test/unit/put_template_test.rb
|
579
|
+
- test/unit/render_search_template_test.rb
|
574
580
|
- test/unit/scroll_test.rb
|
575
581
|
- test/unit/search_exists_test.rb
|
576
582
|
- test/unit/search_shards_test.rb
|
@@ -637,6 +643,7 @@ test_files:
|
|
637
643
|
- test/unit/cat/help_test.rb
|
638
644
|
- test/unit/cat/indices_test.rb
|
639
645
|
- test/unit/cat/master_test.rb
|
646
|
+
- test/unit/cat/nodeattrs_test.rb
|
640
647
|
- test/unit/cat/nodes_test.rb
|
641
648
|
- test/unit/cat/pending_tasks_test.rb
|
642
649
|
- test/unit/cat/plugins_test.rb
|
@@ -702,6 +709,7 @@ test_files:
|
|
702
709
|
- test/unit/indices/refresh_test.rb
|
703
710
|
- test/unit/indices/seal_test.rb
|
704
711
|
- test/unit/indices/segments_test.rb
|
712
|
+
- test/unit/indices/shard_stores_test.rb
|
705
713
|
- test/unit/indices/snapshot_index_test.rb
|
706
714
|
- test/unit/indices/stats_test.rb
|
707
715
|
- test/unit/indices/status_test.rb
|
@@ -724,6 +732,7 @@ test_files:
|
|
724
732
|
- test/unit/ping_test.rb
|
725
733
|
- test/unit/put_script_test.rb
|
726
734
|
- test/unit/put_template_test.rb
|
735
|
+
- test/unit/render_search_template_test.rb
|
727
736
|
- test/unit/scroll_test.rb
|
728
737
|
- test/unit/search_exists_test.rb
|
729
738
|
- test/unit/search_shards_test.rb
|