elasticsearch-api 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -0
- data/Rakefile +3 -3
- data/elasticsearch-api.gemspec +4 -1
- data/lib/elasticsearch/api.rb +19 -0
- data/lib/elasticsearch/api/actions/abort_benchmark.rb +1 -1
- data/lib/elasticsearch/api/actions/benchmark.rb +1 -1
- data/lib/elasticsearch/api/actions/bulk.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/aliases.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/allocation.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/count.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/fielddata.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/health.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/help.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/indices.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/master.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/nodes.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/recovery.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/segments.rb +34 -0
- data/lib/elasticsearch/api/actions/cat/shards.rb +1 -1
- data/lib/elasticsearch/api/actions/cat/thread_pool.rb +1 -1
- data/lib/elasticsearch/api/actions/clear_scroll.rb +12 -3
- data/lib/elasticsearch/api/actions/cluster/get_settings.rb +1 -1
- data/lib/elasticsearch/api/actions/cluster/health.rb +1 -1
- data/lib/elasticsearch/api/actions/cluster/pending_tasks.rb +1 -1
- data/lib/elasticsearch/api/actions/cluster/put_settings.rb +1 -1
- data/lib/elasticsearch/api/actions/cluster/reroute.rb +1 -1
- data/lib/elasticsearch/api/actions/cluster/state.rb +8 -2
- data/lib/elasticsearch/api/actions/count.rb +1 -1
- data/lib/elasticsearch/api/actions/count_percolate.rb +1 -1
- data/lib/elasticsearch/api/actions/delete.rb +1 -1
- data/lib/elasticsearch/api/actions/delete_by_query.rb +1 -1
- data/lib/elasticsearch/api/actions/delete_script.rb +1 -1
- data/lib/elasticsearch/api/actions/delete_template.rb +1 -1
- data/lib/elasticsearch/api/actions/exists.rb +4 -2
- data/lib/elasticsearch/api/actions/explain.rb +1 -1
- data/lib/elasticsearch/api/actions/get.rb +2 -2
- data/lib/elasticsearch/api/actions/get_script.rb +1 -1
- data/lib/elasticsearch/api/actions/get_source.rb +2 -2
- data/lib/elasticsearch/api/actions/get_template.rb +1 -1
- data/lib/elasticsearch/api/actions/index.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/analyze.rb +5 -3
- data/lib/elasticsearch/api/actions/indices/clear_cache.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/close.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/create.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/delete.rb +7 -1
- data/lib/elasticsearch/api/actions/indices/delete_alias.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/delete_mapping.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/delete_template.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/delete_warmer.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/exists.rb +3 -1
- data/lib/elasticsearch/api/actions/indices/exists_alias.rb +3 -1
- data/lib/elasticsearch/api/actions/indices/exists_template.rb +3 -2
- data/lib/elasticsearch/api/actions/indices/exists_type.rb +3 -1
- data/lib/elasticsearch/api/actions/indices/flush.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/get.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/get_alias.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/get_aliases.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +1 -1
- 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 +3 -2
- data/lib/elasticsearch/api/actions/indices/get_warmer.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/open.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/optimize.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/put_alias.rb +2 -2
- data/lib/elasticsearch/api/actions/indices/put_mapping.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/put_settings.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/put_template.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/put_warmer.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/recovery.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/refresh.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/segments.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/snapshot_index.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/stats.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/status.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/update_aliases.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/upgrade.rb +1 -1
- data/lib/elasticsearch/api/actions/indices/validate_query.rb +1 -1
- data/lib/elasticsearch/api/actions/info.rb +1 -1
- data/lib/elasticsearch/api/actions/list_benchmarks.rb +1 -1
- data/lib/elasticsearch/api/actions/mget.rb +1 -1
- data/lib/elasticsearch/api/actions/mlt.rb +1 -1
- data/lib/elasticsearch/api/actions/mpercolate.rb +1 -1
- data/lib/elasticsearch/api/actions/msearch.rb +1 -1
- data/lib/elasticsearch/api/actions/mtermvectors.rb +1 -1
- data/lib/elasticsearch/api/actions/nodes/hot_threads.rb +1 -1
- data/lib/elasticsearch/api/actions/nodes/info.rb +18 -2
- data/lib/elasticsearch/api/actions/nodes/shutdown.rb +1 -1
- data/lib/elasticsearch/api/actions/nodes/stats.rb +1 -1
- data/lib/elasticsearch/api/actions/percolate.rb +4 -5
- data/lib/elasticsearch/api/actions/ping.rb +1 -1
- data/lib/elasticsearch/api/actions/put_script.rb +1 -1
- data/lib/elasticsearch/api/actions/put_template.rb +1 -1
- data/lib/elasticsearch/api/actions/scroll.rb +2 -2
- data/lib/elasticsearch/api/actions/search.rb +4 -3
- data/lib/elasticsearch/api/actions/search_shards.rb +1 -1
- data/lib/elasticsearch/api/actions/search_template.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/create.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/create_repository.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/delete.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/get.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/restore.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/status.rb +1 -1
- data/lib/elasticsearch/api/actions/snapshot/verify_repository.rb +1 -1
- data/lib/elasticsearch/api/actions/suggest.rb +1 -1
- data/lib/elasticsearch/api/actions/{termvector.rb → termvectors.rb} +24 -7
- data/lib/elasticsearch/api/actions/update.rb +1 -1
- data/lib/elasticsearch/api/utils.rb +27 -6
- data/lib/elasticsearch/api/version.rb +1 -1
- data/test/integration/yaml_test_runner.rb +3 -2
- data/test/unit/api_test.rb +24 -0
- data/test/unit/cat/segments_test.rb +26 -0
- data/test/unit/clear_scroll_test.rb +4 -4
- data/test/unit/exists_document_test.rb +5 -0
- data/test/unit/indices/delete_test.rb +7 -0
- data/test/unit/indices/exists_alias_test.rb +5 -0
- data/test/unit/indices/exists_test.rb +5 -0
- data/test/unit/indices/exists_type_test.rb +5 -0
- data/test/unit/indices/put_alias_test.rb +9 -0
- data/test/unit/nodes/info_test.rb +9 -0
- data/test/unit/scroll_test.rb +1 -2
- data/test/unit/{termvector_test.rb → termvectors_test.rb} +15 -12
- data/test/unit/utils_test.rb +22 -0
- data/utils/Gemfile +9 -0
- data/utils/Thorfile +3 -0
- data/utils/thor/generate_api.rb +189 -0
- data/utils/thor/generate_source.rb +122 -0
- data/utils/thor/lister.rb +41 -0
- data/utils/thor/templates/ruby/method.erb +62 -0
- data/utils/thor/templates/ruby/test.erb +26 -0
- data/utils/thor/templates/ruby/test_helper.rb +71 -0
- metadata +18 -5
@@ -26,7 +26,7 @@ module Elasticsearch
|
|
26
26
|
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
|
27
27
|
valid_params = [ :create, :order, :timeout ]
|
28
28
|
|
29
|
-
method =
|
29
|
+
method = HTTP_PUT
|
30
30
|
path = Utils.__pathify '_template', Utils.__escape(arguments[:name])
|
31
31
|
|
32
32
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
@@ -29,7 +29,7 @@ module Elasticsearch
|
|
29
29
|
:detailed,
|
30
30
|
:active_only,
|
31
31
|
:human ]
|
32
|
-
method =
|
32
|
+
method = HTTP_GET
|
33
33
|
path = Utils.__pathify Utils.__listify(arguments[:index]), '_recovery'
|
34
34
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
35
35
|
body = nil
|
@@ -101,7 +101,7 @@ module Elasticsearch
|
|
101
101
|
:allow_no_indices,
|
102
102
|
:expand_wildcards ]
|
103
103
|
|
104
|
-
method =
|
104
|
+
method = HTTP_GET
|
105
105
|
|
106
106
|
parts = Utils.__extract_parts arguments, valid_parts
|
107
107
|
path = Utils.__pathify Utils.__listify(arguments[:index]), '_stats', Utils.__listify(parts)
|
@@ -34,7 +34,7 @@ module Elasticsearch
|
|
34
34
|
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
|
35
35
|
valid_params = [ :timeout ]
|
36
36
|
|
37
|
-
method =
|
37
|
+
method = HTTP_POST
|
38
38
|
path = "_aliases"
|
39
39
|
|
40
40
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
@@ -39,7 +39,7 @@ module Elasticsearch
|
|
39
39
|
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
|
40
40
|
valid_params = [ :search_type ]
|
41
41
|
|
42
|
-
method =
|
42
|
+
method = HTTP_GET
|
43
43
|
path = Utils.__pathify( Utils.__listify(arguments[:index]), Utils.__listify(arguments[:type]), '_msearch' )
|
44
44
|
|
45
45
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
@@ -14,6 +14,14 @@ module Elasticsearch
|
|
14
14
|
#
|
15
15
|
# client.nodes.info jvm: true
|
16
16
|
#
|
17
|
+
# @example Return information about HTTP and network
|
18
|
+
#
|
19
|
+
# client.nodes.info http: true, network: true
|
20
|
+
#
|
21
|
+
# @example Pass a list of metrics
|
22
|
+
#
|
23
|
+
# client.nodes.info metric: ['http', 'network']
|
24
|
+
#
|
17
25
|
# @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information;
|
18
26
|
# use `_local` to return information from the node you're connecting to, leave
|
19
27
|
# empty to get information from all nodes
|
@@ -31,6 +39,9 @@ module Elasticsearch
|
|
31
39
|
# @see http://elasticsearch.org/guide/reference/api/admin-cluster-nodes-info/
|
32
40
|
#
|
33
41
|
def info(arguments={})
|
42
|
+
arguments = arguments.clone
|
43
|
+
metric = arguments.delete(:metric)
|
44
|
+
|
34
45
|
valid_parts = [
|
35
46
|
:_all,
|
36
47
|
:http,
|
@@ -45,9 +56,14 @@ module Elasticsearch
|
|
45
56
|
|
46
57
|
valid_params = []
|
47
58
|
|
48
|
-
method =
|
59
|
+
method = HTTP_GET
|
60
|
+
|
61
|
+
if metric
|
62
|
+
parts = metric
|
63
|
+
else
|
64
|
+
parts = Utils.__extract_parts arguments, valid_parts
|
65
|
+
end
|
49
66
|
|
50
|
-
parts = Utils.__extract_parts arguments, valid_parts
|
51
67
|
path = Utils.__pathify '_nodes', Utils.__listify(arguments[:node_id]), Utils.__listify(parts)
|
52
68
|
|
53
69
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
@@ -21,10 +21,10 @@ module Elasticsearch
|
|
21
21
|
#
|
22
22
|
# @example Evaluate a custom document (passed as `:doc`) against the queries
|
23
23
|
#
|
24
|
-
# client.percolate index: 'my-index', body: { doc: { title: "Foo" } }
|
24
|
+
# client.percolate index: 'my-index', type: 'my-type', body: { doc: { title: "Foo" } }
|
25
25
|
# # => {..., matches: [ {_index: 'my-index', _id: 'alert-1'} ]}
|
26
26
|
#
|
27
|
-
# client.percolate index: 'my-index', body: { doc: { title: "Foo Bar" } }
|
27
|
+
# client.percolate index: 'my-index', type: 'my-type', body: { doc: { title: "Foo Bar" } }
|
28
28
|
# # => {..., matches: [ {_index: 'my-index', _id: 'alert-2'}, {_index: 'my-index', _id: 'alert-1'} ] }
|
29
29
|
#
|
30
30
|
# @example Evaluate an existing document against the queries
|
@@ -44,13 +44,12 @@ module Elasticsearch
|
|
44
44
|
#
|
45
45
|
# @example Evaluate a document against "high priority" percolator queries
|
46
46
|
#
|
47
|
-
# client.percolate index: 'my-index', body: {
|
47
|
+
# client.percolate index: 'my-index', type: 'my-type', body: {
|
48
48
|
# doc: { title: "Foo" },
|
49
49
|
# filter: { term: { priority: 'high' } }
|
50
50
|
# }
|
51
51
|
# # => {..., matches: [ {_index: 'my-index', _id: 'alert-high-1'} ]}
|
52
52
|
#
|
53
|
-
#
|
54
53
|
# @option arguments [String] :index The index of the document being percolated. (*Required*)
|
55
54
|
# @option arguments [String] :type The type of the document being percolated. (*Required*)
|
56
55
|
# @option arguments [String] :id Fetch the document specified by index/type/id and
|
@@ -91,7 +90,7 @@ module Elasticsearch
|
|
91
90
|
:version,
|
92
91
|
:version_type ]
|
93
92
|
|
94
|
-
method =
|
93
|
+
method = HTTP_GET
|
95
94
|
path = Utils.__pathify Utils.__escape(arguments[:index]),
|
96
95
|
Utils.__escape(arguments[:type]),
|
97
96
|
arguments[:id],
|
@@ -13,7 +13,7 @@ module Elasticsearch
|
|
13
13
|
def put_template(arguments={})
|
14
14
|
raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
|
15
15
|
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
|
16
|
-
method =
|
16
|
+
method = HTTP_PUT
|
17
17
|
path = "_search/template/#{arguments[:id]}"
|
18
18
|
params = {}
|
19
19
|
body = arguments[:body]
|
@@ -44,14 +44,14 @@ module Elasticsearch
|
|
44
44
|
# @see http://www.elasticsearch.org/guide/reference/api/search/search-type/
|
45
45
|
#
|
46
46
|
def scroll(arguments={})
|
47
|
-
method =
|
47
|
+
method = HTTP_GET
|
48
48
|
path = "_search/scroll"
|
49
49
|
valid_params = [
|
50
50
|
:scroll,
|
51
51
|
:scroll_id ]
|
52
52
|
|
53
53
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
54
|
-
body = arguments[:body]
|
54
|
+
body = params.delete(:scroll_id) || arguments[:body]
|
55
55
|
|
56
56
|
perform_request(method, path, params, body).body
|
57
57
|
end
|
@@ -112,7 +112,7 @@ module Elasticsearch
|
|
112
112
|
# @see http://www.elasticsearch.org/guide/reference/api/search/request-body/
|
113
113
|
#
|
114
114
|
def search(arguments={})
|
115
|
-
arguments[:index] =
|
115
|
+
arguments[:index] = UNDERSCORE_ALL if ! arguments[:index] && arguments[:type]
|
116
116
|
|
117
117
|
valid_params = [
|
118
118
|
:analyzer,
|
@@ -130,6 +130,7 @@ module Elasticsearch
|
|
130
130
|
:lowercase_expanded_terms,
|
131
131
|
:preference,
|
132
132
|
:q,
|
133
|
+
:query_cache,
|
133
134
|
:routing,
|
134
135
|
:scroll,
|
135
136
|
:search_type,
|
@@ -147,8 +148,8 @@ module Elasticsearch
|
|
147
148
|
:timeout,
|
148
149
|
:version ]
|
149
150
|
|
150
|
-
method =
|
151
|
-
path = Utils.__pathify( Utils.__listify(arguments[:index]), Utils.__listify(arguments[:type]),
|
151
|
+
method = HTTP_GET
|
152
|
+
path = Utils.__pathify( Utils.__listify(arguments[:index]), Utils.__listify(arguments[:type]), UNDERSCORE_SEARCH )
|
152
153
|
|
153
154
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
154
155
|
body = arguments[:body]
|
@@ -29,7 +29,7 @@ module Elasticsearch
|
|
29
29
|
:ignore_unavailable,
|
30
30
|
:allow_no_indices,
|
31
31
|
:expand_wildcards ]
|
32
|
-
method =
|
32
|
+
method = HTTP_GET
|
33
33
|
path = Utils.__pathify( Utils.__listify(arguments[:index]), Utils.__listify(arguments[:type]), '_search_shards' )
|
34
34
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
35
35
|
body = nil
|
@@ -49,7 +49,7 @@ module Elasticsearch
|
|
49
49
|
:routing,
|
50
50
|
:scroll,
|
51
51
|
:search_type ]
|
52
|
-
method =
|
52
|
+
method = HTTP_GET
|
53
53
|
path = Utils.__pathify( Utils.__listify(arguments[:index]), Utils.__listify(arguments[:type]), '_search/template' )
|
54
54
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
55
55
|
body = arguments[:body]
|
@@ -34,7 +34,7 @@ module Elasticsearch
|
|
34
34
|
repository = arguments.delete(:repository)
|
35
35
|
snapshot = arguments.delete(:snapshot)
|
36
36
|
|
37
|
-
method =
|
37
|
+
method = HTTP_PUT
|
38
38
|
path = Utils.__pathify( '_snapshot', Utils.__escape(repository), Utils.__escape(snapshot) )
|
39
39
|
|
40
40
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
@@ -27,7 +27,7 @@ module Elasticsearch
|
|
27
27
|
repository = arguments.delete(:repository)
|
28
28
|
snapshot = arguments.delete(:snapshot)
|
29
29
|
|
30
|
-
method =
|
30
|
+
method = HTTP_DELETE
|
31
31
|
path = Utils.__pathify( '_snapshot', Utils.__escape(repository), Utils.__listify(snapshot) )
|
32
32
|
|
33
33
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
@@ -24,7 +24,7 @@ module Elasticsearch
|
|
24
24
|
|
25
25
|
repository = arguments.delete(:repository)
|
26
26
|
|
27
|
-
method =
|
27
|
+
method = HTTP_DELETE
|
28
28
|
path = Utils.__pathify( '_snapshot', Utils.__listify(repository) )
|
29
29
|
|
30
30
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
@@ -33,7 +33,7 @@ module Elasticsearch
|
|
33
33
|
repository = arguments.delete(:repository)
|
34
34
|
snapshot = arguments.delete(:snapshot)
|
35
35
|
|
36
|
-
method =
|
36
|
+
method = HTTP_GET
|
37
37
|
path = Utils.__pathify( '_snapshot', Utils.__escape(repository), Utils.__listify(snapshot) )
|
38
38
|
|
39
39
|
params = Utils.__validate_and_extract_params arguments, valid_params
|