elasticsearch-api 1.0.6 → 1.0.7
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.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25fb9700e6298b2c6a37cd1a114041689e9cbfd4
|
4
|
+
data.tar.gz: c04e61a9efce06dbecdec9f45681259dc3a26ff5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 570c0084b961fccc4741ba790dc93edef6562027c531c3019535143c2e1161dcfbb064058eb55016afce2bced5a70126c7a24e062728ae5e44be8ff9d01bc661
|
7
|
+
data.tar.gz: bbe4bc6dd89766e037af5ac4ac38abd80f7df830caf3a75f221a5874266cc0275f6a6ba4e1028a1893a4788dd1a184043e1dca95f384686addf90aec3ee37750
|
data/README.md
CHANGED
@@ -155,6 +155,22 @@ mash.facets.tags.terms.first
|
|
155
155
|
# => #<Hashie::Mash count=3 term="z">
|
156
156
|
```
|
157
157
|
|
158
|
+
## Development
|
159
|
+
|
160
|
+
To work on the code, clone and bootstrap the main repository first --
|
161
|
+
please see instructions in the main [README](../README.md#development).
|
162
|
+
|
163
|
+
To run tests, launch a testing cluster -- again, see instructions
|
164
|
+
in the main [README](../README.md#development) -- and use the Rake tasks:
|
165
|
+
|
166
|
+
```
|
167
|
+
time rake test:unit
|
168
|
+
time rake test:integration
|
169
|
+
```
|
170
|
+
|
171
|
+
Unit tests have to use Ruby 1.8 compatible syntax, integration tests
|
172
|
+
can use Ruby 2.x syntax and features.
|
173
|
+
|
158
174
|
## License
|
159
175
|
|
160
176
|
This software is licensed under the Apache 2 license, quoted below.
|
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ def __current__
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def git_specs(command, options={})
|
8
|
-
sh "git --git-dir=#{__current__.join('../
|
8
|
+
sh "git --git-dir=#{__current__.join('../tmp/elasticsearch/.git')} --work-tree=#{__current__.join('../tmp/elasticsearch')} #{command}", options
|
9
9
|
end
|
10
10
|
|
11
11
|
task(:default) { system "rake --tasks" }
|
@@ -44,7 +44,7 @@ namespace :test do
|
|
44
44
|
task :integration do
|
45
45
|
require 'elasticsearch'
|
46
46
|
|
47
|
-
branches = `git --git-dir=#{__current__.join('../
|
47
|
+
branches = `git --git-dir=#{__current__.join('../tmp/elasticsearch/.git')} --work-tree=#{__current__.join('../tmp/elasticsearch')} branch --no-color`
|
48
48
|
|
49
49
|
current_branch = branches.
|
50
50
|
split("\n").
|
@@ -98,7 +98,7 @@ namespace :test do
|
|
98
98
|
end
|
99
99
|
|
100
100
|
# Path to the API specs
|
101
|
-
ENV['TEST_REST_API_SPEC'] = __current__.join('../
|
101
|
+
ENV['TEST_REST_API_SPEC'] = __current__.join('../tmp/elasticsearch/rest-api-spec/test/').to_s
|
102
102
|
|
103
103
|
# Run the task
|
104
104
|
args = [t.ruby_opts_string, t.run_code, t.file_list_string, t.option_list].join(' ')
|
data/elasticsearch-api.gemspec
CHANGED
@@ -48,7 +48,6 @@ Gem::Specification.new do |s|
|
|
48
48
|
# Prevent unit test failures on Ruby 1.8
|
49
49
|
if defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
|
50
50
|
s.add_development_dependency "test-unit", '~> 2'
|
51
|
-
s.add_development_dependency "activesupport", '~> 3'
|
52
51
|
s.add_development_dependency "json"
|
53
52
|
end
|
54
53
|
|
@@ -62,6 +61,10 @@ Gem::Specification.new do |s|
|
|
62
61
|
s.add_development_dependency "require-prof" unless defined?(JRUBY_VERSION) || defined?(Rubinius)
|
63
62
|
end
|
64
63
|
|
64
|
+
if defined?(RUBY_VERSION) && RUBY_VERSION > '2.2'
|
65
|
+
s.add_development_dependency "test-unit", '~> 2'
|
66
|
+
end
|
67
|
+
|
65
68
|
s.description = <<-DESC.gsub(/^ /, '')
|
66
69
|
Ruby API for Elasticsearch. See the `elasticsearch` gem for full integration.
|
67
70
|
DESC
|
data/lib/elasticsearch/api.rb
CHANGED
@@ -25,6 +25,14 @@ module Elasticsearch
|
|
25
25
|
:human # Return numeric values in human readable format
|
26
26
|
]
|
27
27
|
|
28
|
+
HTTP_GET = 'GET'.freeze
|
29
|
+
HTTP_HEAD = 'HEAD'.freeze
|
30
|
+
HTTP_POST = 'POST'.freeze
|
31
|
+
HTTP_PUT = 'PUT'.freeze
|
32
|
+
HTTP_DELETE = 'DELETE'.freeze
|
33
|
+
UNDERSCORE_SEARCH = '_search'.freeze
|
34
|
+
UNDERSCORE_ALL = '_all'.freeze
|
35
|
+
|
28
36
|
# Auto-include all namespaces in the receiver
|
29
37
|
#
|
30
38
|
def self.included(base)
|
@@ -37,5 +45,16 @@ module Elasticsearch
|
|
37
45
|
Elasticsearch::API::Snapshot,
|
38
46
|
Elasticsearch::API::Cat
|
39
47
|
end
|
48
|
+
|
49
|
+
module ClassMethods
|
50
|
+
|
51
|
+
# Access the module settings
|
52
|
+
#
|
53
|
+
def settings
|
54
|
+
@settings ||= {}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
extend ClassMethods
|
40
59
|
end
|
41
60
|
end
|
@@ -65,7 +65,7 @@ module Elasticsearch
|
|
65
65
|
:type,
|
66
66
|
:timeout ]
|
67
67
|
|
68
|
-
method =
|
68
|
+
method = HTTP_POST
|
69
69
|
path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(arguments[:type]), '_bulk'
|
70
70
|
|
71
71
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Cat
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Display information about the segments in the shards of an index
|
7
|
+
#
|
8
|
+
# @example Display information for all indices
|
9
|
+
#
|
10
|
+
# puts client.cat.segments
|
11
|
+
#
|
12
|
+
# @option arguments [List] :index A comma-separated list of index names to limit the returned information
|
13
|
+
# @option arguments [List] :h Comma-separated list of column names to display
|
14
|
+
# @option arguments [Boolean] :help Return help information
|
15
|
+
# @option arguments [Boolean] :v Verbose mode. Display column headers
|
16
|
+
#
|
17
|
+
# @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat-segments.html
|
18
|
+
#
|
19
|
+
def segments(arguments={})
|
20
|
+
valid_params = [
|
21
|
+
:h,
|
22
|
+
:help,
|
23
|
+
:v ]
|
24
|
+
method = 'GET'
|
25
|
+
path = "_cat/segments"
|
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
|
@@ -12,10 +12,19 @@ module Elasticsearch
|
|
12
12
|
def clear_scroll(arguments={})
|
13
13
|
raise ArgumentError, "Required argument 'scroll_id' missing" unless arguments[:scroll_id]
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
scroll_id = arguments.delete(:scroll_id)
|
16
|
+
|
17
|
+
scroll_ids = case scroll_id
|
18
|
+
when Array
|
19
|
+
scroll_id.join(',')
|
20
|
+
else
|
21
|
+
scroll_id
|
22
|
+
end
|
23
|
+
|
24
|
+
method = HTTP_DELETE
|
25
|
+
path = Utils.__pathify '_search/scroll'
|
17
26
|
params = {}
|
18
|
-
body =
|
27
|
+
body = scroll_ids
|
19
28
|
|
20
29
|
perform_request(method, path, params, body).body
|
21
30
|
end
|
@@ -17,7 +17,7 @@ module Elasticsearch
|
|
17
17
|
def put_settings(arguments={})
|
18
18
|
valid_params = [ :flat_settings ]
|
19
19
|
|
20
|
-
method =
|
20
|
+
method = HTTP_PUT
|
21
21
|
path = "_cluster/settings"
|
22
22
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
23
23
|
body = arguments[:body] || {}
|
@@ -32,7 +32,7 @@ module Elasticsearch
|
|
32
32
|
def reroute(arguments={})
|
33
33
|
valid_params = [ :dry_run, :explain, :metric, :master_timeout, :timeout ]
|
34
34
|
|
35
|
-
method =
|
35
|
+
method = HTTP_POST
|
36
36
|
path = "_cluster/reroute"
|
37
37
|
|
38
38
|
params = Utils.__validate_and_extract_params arguments, valid_params
|
@@ -19,6 +19,10 @@ module Elasticsearch
|
|
19
19
|
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
|
20
20
|
# (default: false)
|
21
21
|
# @option arguments [Time] :master_timeout Specify timeout for connection to master
|
22
|
+
# @option arguments [String] :expand_wildcards Whether to expand wildcard expression for inidices
|
23
|
+
# (options: open, closed)
|
24
|
+
# @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
|
25
|
+
# unavailable (missing, closed, etc)
|
22
26
|
#
|
23
27
|
# @see http://elasticsearch.org/guide/reference/api/admin-cluster-state/
|
24
28
|
#
|
@@ -32,9 +36,11 @@ module Elasticsearch
|
|
32
36
|
:index_templates,
|
33
37
|
:local,
|
34
38
|
:master_timeout,
|
35
|
-
:flat_settings
|
39
|
+
:flat_settings,
|
40
|
+
:expand_wildcards,
|
41
|
+
:ignore_unavailable ]
|
36
42
|
|
37
|
-
method =
|
43
|
+
method = HTTP_GET
|
38
44
|
path = "_cluster/state"
|
39
45
|
|
40
46
|
path = Utils.__pathify '_cluster/state',
|
@@ -45,7 +45,7 @@ module Elasticsearch
|
|
45
45
|
:routing,
|
46
46
|
:source ]
|
47
47
|
|
48
|
-
method =
|
48
|
+
method = HTTP_GET
|
49
49
|
path = Utils.__pathify( Utils.__listify(arguments[:index]), Utils.__listify(arguments[:type]), '_count' )
|
50
50
|
|
51
51
|
params = Utils.__validate_and_extract_params arguments, valid_params
|