elasticsearch-api 0.0.2
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +13 -0
- data/README.md +160 -0
- data/Rakefile +62 -0
- data/elasticsearch-api.gemspec +51 -0
- data/lib/elasticsearch-api +1 -0
- data/lib/elasticsearch/api.rb +23 -0
- data/lib/elasticsearch/api/actions/bulk.rb +71 -0
- data/lib/elasticsearch/api/actions/cluster/get_settings.rb +21 -0
- data/lib/elasticsearch/api/actions/cluster/health.rb +50 -0
- data/lib/elasticsearch/api/actions/cluster/node_hot_threads.rb +46 -0
- data/lib/elasticsearch/api/actions/cluster/node_info.rb +59 -0
- data/lib/elasticsearch/api/actions/cluster/node_shutdown.rb +36 -0
- data/lib/elasticsearch/api/actions/cluster/node_stats.rb +77 -0
- data/lib/elasticsearch/api/actions/cluster/put_settings.rb +28 -0
- data/lib/elasticsearch/api/actions/cluster/reroute.rb +44 -0
- data/lib/elasticsearch/api/actions/cluster/state.rb +47 -0
- data/lib/elasticsearch/api/actions/count.rb +46 -0
- data/lib/elasticsearch/api/actions/create.rb +34 -0
- data/lib/elasticsearch/api/actions/delete.rb +61 -0
- data/lib/elasticsearch/api/actions/delete_by_query.rb +62 -0
- data/lib/elasticsearch/api/actions/exists.rb +51 -0
- data/lib/elasticsearch/api/actions/explain.rb +71 -0
- data/lib/elasticsearch/api/actions/get.rb +59 -0
- data/lib/elasticsearch/api/actions/get_source.rb +59 -0
- data/lib/elasticsearch/api/actions/index.rb +81 -0
- data/lib/elasticsearch/api/actions/indices/analyze.rb +63 -0
- data/lib/elasticsearch/api/actions/indices/clear_cache.rb +69 -0
- data/lib/elasticsearch/api/actions/indices/close.rb +35 -0
- data/lib/elasticsearch/api/actions/indices/create.rb +83 -0
- data/lib/elasticsearch/api/actions/indices/delete.rb +48 -0
- data/lib/elasticsearch/api/actions/indices/delete_alias.rb +37 -0
- data/lib/elasticsearch/api/actions/indices/delete_mapping.rb +26 -0
- data/lib/elasticsearch/api/actions/indices/delete_template.rb +33 -0
- data/lib/elasticsearch/api/actions/indices/delete_warmer.rb +32 -0
- data/lib/elasticsearch/api/actions/indices/exists.rb +35 -0
- data/lib/elasticsearch/api/actions/indices/exists_alias.rb +41 -0
- data/lib/elasticsearch/api/actions/indices/exists_type.rb +39 -0
- data/lib/elasticsearch/api/actions/indices/flush.rb +40 -0
- data/lib/elasticsearch/api/actions/indices/get_alias.rb +41 -0
- data/lib/elasticsearch/api/actions/indices/get_aliases.rb +32 -0
- data/lib/elasticsearch/api/actions/indices/get_mapping.rb +36 -0
- data/lib/elasticsearch/api/actions/indices/get_settings.rb +32 -0
- data/lib/elasticsearch/api/actions/indices/get_template.rb +30 -0
- data/lib/elasticsearch/api/actions/indices/get_warmer.rb +44 -0
- data/lib/elasticsearch/api/actions/indices/open.rb +33 -0
- data/lib/elasticsearch/api/actions/indices/optimize.rb +57 -0
- data/lib/elasticsearch/api/actions/indices/put_alias.rb +43 -0
- data/lib/elasticsearch/api/actions/indices/put_mapping.rb +49 -0
- data/lib/elasticsearch/api/actions/indices/put_settings.rb +45 -0
- data/lib/elasticsearch/api/actions/indices/put_template.rb +40 -0
- data/lib/elasticsearch/api/actions/indices/put_warmer.rb +48 -0
- data/lib/elasticsearch/api/actions/indices/refresh.rb +43 -0
- data/lib/elasticsearch/api/actions/indices/segments.rb +33 -0
- data/lib/elasticsearch/api/actions/indices/snapshot_index.rb +32 -0
- data/lib/elasticsearch/api/actions/indices/stats.rb +96 -0
- data/lib/elasticsearch/api/actions/indices/status.rb +46 -0
- data/lib/elasticsearch/api/actions/indices/update_aliases.rb +49 -0
- data/lib/elasticsearch/api/actions/indices/validate_query.rb +68 -0
- data/lib/elasticsearch/api/actions/info.rb +19 -0
- data/lib/elasticsearch/api/actions/mget.rb +64 -0
- data/lib/elasticsearch/api/actions/mlt.rb +86 -0
- data/lib/elasticsearch/api/actions/msearch.rb +75 -0
- data/lib/elasticsearch/api/actions/percolate.rb +57 -0
- data/lib/elasticsearch/api/actions/ping.rb +29 -0
- data/lib/elasticsearch/api/actions/scroll.rb +44 -0
- data/lib/elasticsearch/api/actions/search.rb +145 -0
- data/lib/elasticsearch/api/actions/suggest.rb +46 -0
- data/lib/elasticsearch/api/actions/update.rb +103 -0
- data/lib/elasticsearch/api/namespace/cluster.rb +20 -0
- data/lib/elasticsearch/api/namespace/common.rb +27 -0
- data/lib/elasticsearch/api/namespace/indices.rb +20 -0
- data/lib/elasticsearch/api/utils.rb +97 -0
- data/lib/elasticsearch/api/version.rb +5 -0
- data/test/integration/yaml_test_runner.rb +330 -0
- data/test/test_helper.rb +52 -0
- data/test/unit/bulk_test.rb +85 -0
- data/test/unit/client_test.rb +31 -0
- data/test/unit/cluster/get_settings_test.rb +26 -0
- data/test/unit/cluster/health_test.rb +38 -0
- data/test/unit/cluster/node_hot_threads_test.rb +35 -0
- data/test/unit/cluster/node_info_test.rb +45 -0
- data/test/unit/cluster/node_shutdown_test.rb +45 -0
- data/test/unit/cluster/node_stats_test.rb +65 -0
- data/test/unit/cluster/put_settings_test.rb +26 -0
- data/test/unit/cluster/reroute_test.rb +38 -0
- data/test/unit/cluster/state_test.rb +37 -0
- data/test/unit/count_test.rb +46 -0
- data/test/unit/create_document_test.rb +38 -0
- data/test/unit/delete_by_query_test.rb +42 -0
- data/test/unit/delete_document_test.rb +62 -0
- data/test/unit/exists_document_test.rb +76 -0
- data/test/unit/explain_document_test.rb +64 -0
- data/test/unit/get_document_source_test.rb +62 -0
- data/test/unit/get_document_test.rb +62 -0
- data/test/unit/hashie_test.rb +78 -0
- data/test/unit/index_document_test.rb +77 -0
- data/test/unit/indices/analyze_test.rb +67 -0
- data/test/unit/indices/clear_cache_test.rb +45 -0
- data/test/unit/indices/close_test.rb +42 -0
- data/test/unit/indices/create_test.rb +42 -0
- data/test/unit/indices/delete_alias_test.rb +38 -0
- data/test/unit/indices/delete_mapping_test.rb +47 -0
- data/test/unit/indices/delete_template_test.rb +26 -0
- data/test/unit/indices/delete_test.rb +45 -0
- data/test/unit/indices/delete_warmer_test.rb +59 -0
- data/test/unit/indices/exists_alias_test.rb +65 -0
- data/test/unit/indices/exists_test.rb +57 -0
- data/test/unit/indices/exists_type_test.rb +59 -0
- data/test/unit/indices/flush_test.rb +45 -0
- data/test/unit/indices/get_alias_test.rb +41 -0
- data/test/unit/indices/get_aliases_test.rb +35 -0
- data/test/unit/indices/get_mapping_test.rb +53 -0
- data/test/unit/indices/get_settings_test.rb +35 -0
- data/test/unit/indices/get_template_test.rb +32 -0
- data/test/unit/indices/get_warmer_test.rb +41 -0
- data/test/unit/indices/open_test.rb +42 -0
- data/test/unit/indices/optimize_test.rb +45 -0
- data/test/unit/indices/put_alias_test.rb +47 -0
- data/test/unit/indices/put_mapping_test.rb +57 -0
- data/test/unit/indices/put_settings_test.rb +50 -0
- data/test/unit/indices/put_template_test.rb +48 -0
- data/test/unit/indices/put_warmer_test.rb +62 -0
- data/test/unit/indices/refresh_test.rb +55 -0
- data/test/unit/indices/segments_test.rb +55 -0
- data/test/unit/indices/snapshot_index_test.rb +55 -0
- data/test/unit/indices/stats_test.rb +76 -0
- data/test/unit/indices/status_test.rb +55 -0
- data/test/unit/indices/update_aliases_test.rb +42 -0
- data/test/unit/indices/validate_query_test.rb +75 -0
- data/test/unit/info_test.rb +26 -0
- data/test/unit/json_builders_test.rb +64 -0
- data/test/unit/mget_test.rb +70 -0
- data/test/unit/mlt_test.rb +80 -0
- data/test/unit/msearch_test.rb +120 -0
- data/test/unit/percolate_test.rb +49 -0
- data/test/unit/ping_test.rb +48 -0
- data/test/unit/scroll_test.rb +26 -0
- data/test/unit/search_test.rb +93 -0
- data/test/unit/suggest_test.rb +55 -0
- data/test/unit/update_document_test.rb +62 -0
- data/test/unit/utils_test.rb +118 -0
- metadata +498 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Cluster
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Returns information about cluster "health".
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
#
|
10
|
+
# client.cluster.health
|
11
|
+
#
|
12
|
+
# @option arguments [String] :index Limit the information returned to a specific index
|
13
|
+
# @option arguments [String] :level Specify the level of detail for returned information
|
14
|
+
# (options: cluster, indices, shards)
|
15
|
+
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
|
16
|
+
# (default: false)
|
17
|
+
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
|
18
|
+
# @option arguments [Time] :timeout Explicit operation timeout
|
19
|
+
# @option arguments [Number] :wait_for_active_shards Wait until the specified number of shards is active
|
20
|
+
# @option arguments [Number] :wait_for_nodes Wait until the specified number of nodes is available
|
21
|
+
# @option arguments [Number] :wait_for_relocating_shards Wait until the specified number of relocating
|
22
|
+
# shards is finished
|
23
|
+
# @option arguments [String] :wait_for_status Wait until cluster is in a specific state
|
24
|
+
# (options: green, yellow, red)
|
25
|
+
#
|
26
|
+
# @see http://elasticsearch.org/guide/reference/api/admin-cluster-health/
|
27
|
+
#
|
28
|
+
def health(arguments={})
|
29
|
+
method = 'GET'
|
30
|
+
path = "_cluster/health"
|
31
|
+
params = arguments.select do |k,v|
|
32
|
+
[ :level,
|
33
|
+
:local,
|
34
|
+
:master_timeout,
|
35
|
+
:timeout,
|
36
|
+
:wait_for_active_shards,
|
37
|
+
:wait_for_nodes,
|
38
|
+
:wait_for_relocating_shards,
|
39
|
+
:wait_for_status ].include?(k)
|
40
|
+
end
|
41
|
+
# Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
|
42
|
+
params = Hash[params] unless params.is_a?(Hash)
|
43
|
+
body = nil
|
44
|
+
|
45
|
+
perform_request(method, path, params, body).body
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Cluster
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Returns information about the hottest threads in the cluster or on a specific node as a String.
|
7
|
+
#
|
8
|
+
#
|
9
|
+
# The information is returned as text, and allows you to understand what are currently
|
10
|
+
# the most taxing operations happening in the cluster, for debugging or monitoring purposes.
|
11
|
+
#
|
12
|
+
# @example Return 10 hottest threads
|
13
|
+
#
|
14
|
+
# client.cluster.node_hot_threads threads: 10
|
15
|
+
#
|
16
|
+
# @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information;
|
17
|
+
# use `_local` to return information from the node you're connecting to,
|
18
|
+
# leave empty to get information from all nodes
|
19
|
+
# @option arguments [Time] :interval The interval for the second sampling of threads
|
20
|
+
# @option arguments [Number] :snapshots Number of samples of thread stacktrace (default: 10)
|
21
|
+
# @option arguments [Number] :threads Specify the number of threads to provide information for (default: 3)
|
22
|
+
# @option arguments [String] :type The type to sample (default: cpu) (options: cpu, wait, block)
|
23
|
+
#
|
24
|
+
# @return [String]
|
25
|
+
#
|
26
|
+
# @see http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-hot-threads/
|
27
|
+
#
|
28
|
+
def node_hot_threads(arguments={})
|
29
|
+
method = 'GET'
|
30
|
+
path = "_cluster/nodes/#{arguments[:node_id]}/hot_threads".squeeze('/')
|
31
|
+
params = arguments.select do |k,v|
|
32
|
+
[ :interval,
|
33
|
+
:snapshots,
|
34
|
+
:threads,
|
35
|
+
:type ].include?(k)
|
36
|
+
end
|
37
|
+
# Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
|
38
|
+
params = Hash[params] unless params.is_a?(Hash)
|
39
|
+
body = nil
|
40
|
+
|
41
|
+
perform_request(method, path, params, body).body
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Cluster
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Returns information about nodes in the cluster (cluster settings, JVM version, etc).
|
7
|
+
#
|
8
|
+
# Use the `all` option to return all available settings, or limit the information returned
|
9
|
+
# to a specific type (eg. `http`).
|
10
|
+
#
|
11
|
+
# Use the `node_id` option to limit information to specific node(s).
|
12
|
+
#
|
13
|
+
# @example Return information about JVM
|
14
|
+
#
|
15
|
+
# client.cluster.node_info jvm: true
|
16
|
+
#
|
17
|
+
# @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information;
|
18
|
+
# use `_local` to return information from the node you're connecting to, leave
|
19
|
+
# empty to get information from all nodes
|
20
|
+
# @option arguments [Boolean] :all Return all available information
|
21
|
+
# @option arguments [Boolean] :clear Reset the default settings
|
22
|
+
# @option arguments [Boolean] :http Return information about HTTP
|
23
|
+
# @option arguments [Boolean] :jvm Return information about the JVM
|
24
|
+
# @option arguments [Boolean] :network Return information about network
|
25
|
+
# @option arguments [Boolean] :os Return information about the operating system
|
26
|
+
# @option arguments [Boolean] :plugin Return information about plugins
|
27
|
+
# @option arguments [Boolean] :process Return information about the Elasticsearch process
|
28
|
+
# @option arguments [Boolean] :settings Return information about node settings
|
29
|
+
# @option arguments [Boolean] :thread_pool Return information about the thread pool
|
30
|
+
# @option arguments [Boolean] :transport Return information about transport
|
31
|
+
#
|
32
|
+
# @see http://elasticsearch.org/guide/reference/api/admin-cluster-nodes-info/
|
33
|
+
#
|
34
|
+
def node_info(arguments={})
|
35
|
+
method = 'GET'
|
36
|
+
path = Utils.__pathify( '_cluster/nodes', Utils.__listify(arguments[:node_id]) )
|
37
|
+
params = arguments.select do |k,v|
|
38
|
+
[ :all,
|
39
|
+
:clear,
|
40
|
+
:http,
|
41
|
+
:jvm,
|
42
|
+
:network,
|
43
|
+
:os,
|
44
|
+
:plugin,
|
45
|
+
:process,
|
46
|
+
:settings,
|
47
|
+
:thread_pool,
|
48
|
+
:transport ].include?(k)
|
49
|
+
end
|
50
|
+
# Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
|
51
|
+
params = Hash[params] unless params.is_a?(Hash)
|
52
|
+
body = nil
|
53
|
+
|
54
|
+
perform_request(method, path, params, body).body
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Cluster
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Shutdown one or all nodes
|
7
|
+
#
|
8
|
+
# @example Shut down node named _Bloke_
|
9
|
+
#
|
10
|
+
# client.cluster.node_shutdown node_id: 'Bloke'
|
11
|
+
#
|
12
|
+
# @option arguments [List] :node_id A comma-separated list of node IDs or names to perform the operation on; use
|
13
|
+
# `_local` to shutdown the node you're connected to, leave empty to
|
14
|
+
# shutdown all nodes
|
15
|
+
# @option arguments [Time] :delay Set the delay for the operation (default: 1s)
|
16
|
+
# @option arguments [Boolean] :exit Exit the JVM as well (default: true)
|
17
|
+
#
|
18
|
+
# @see http://elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown/
|
19
|
+
#
|
20
|
+
def node_shutdown(arguments={})
|
21
|
+
method = 'POST'
|
22
|
+
path = Utils.__pathify( '_cluster/nodes', Utils.__listify(arguments[:node_id]), '_shutdown' )
|
23
|
+
params = arguments.select do |k,v|
|
24
|
+
[ :delay,
|
25
|
+
:exit ].include?(k)
|
26
|
+
end
|
27
|
+
# Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
|
28
|
+
params = Hash[params] unless params.is_a?(Hash)
|
29
|
+
body = nil
|
30
|
+
|
31
|
+
perform_request(method, path, params, body).body
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Cluster
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Returns statistical information about nodes in the cluster.
|
7
|
+
#
|
8
|
+
# @example Return statistics about JVM
|
9
|
+
#
|
10
|
+
# client.cluster.node_stats clear: true, jvm: true
|
11
|
+
#
|
12
|
+
# @option arguments [List] :metric Limit the information returned for `indices` family to a specific metric
|
13
|
+
# (options: docs, fielddata, filter_cache, flush, get, id_cache, indexing, merges,
|
14
|
+
# refresh, search, store, warmer)
|
15
|
+
# @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information;
|
16
|
+
# use `_local` to return information from the node you're connecting to, leave
|
17
|
+
# empty to get information from all nodes
|
18
|
+
# @option arguments [Boolean] :all Return all available information
|
19
|
+
# @option arguments [Boolean] :clear Reset the default level of detail
|
20
|
+
# @option arguments [List] :fields A comma-separated list of fields for `fielddata` metric (supports wildcards)
|
21
|
+
# @option arguments [Boolean] :fs Return information about the filesystem
|
22
|
+
# @option arguments [Boolean] :http Return information about HTTP
|
23
|
+
# @option arguments [Boolean] :indices Return information about indices
|
24
|
+
# @option arguments [Boolean] :jvm Return information about the JVM
|
25
|
+
# @option arguments [Boolean] :network Return information about network
|
26
|
+
# @option arguments [Boolean] :os Return information about the operating system
|
27
|
+
# @option arguments [Boolean] :process Return information about the Elasticsearch process
|
28
|
+
# @option arguments [Boolean] :thread_pool Return information about the thread pool
|
29
|
+
# @option arguments [Boolean] :transport Return information about transport
|
30
|
+
#
|
31
|
+
# @see http://elasticsearch.org/guide/reference/api/admin-cluster-nodes-stats/
|
32
|
+
#
|
33
|
+
def node_stats(arguments={})
|
34
|
+
method = 'GET'
|
35
|
+
|
36
|
+
case
|
37
|
+
# Field data metric for the `indices` metric family
|
38
|
+
when arguments[:indices] && arguments[:metric] == 'fielddata'
|
39
|
+
path = Utils.__pathify( '_nodes', Utils.__listify(arguments[:node_id]), 'stats/indices/fielddata' )
|
40
|
+
params = { :fields => Utils.__listify(arguments[:fields]) }
|
41
|
+
|
42
|
+
# `indices` metric family incl. a metric
|
43
|
+
when arguments[:indices] && arguments[:metric]
|
44
|
+
path = Utils.__pathify( '_nodes', Utils.__listify(arguments[:node_id]), 'stats/indices', arguments[:metric] )
|
45
|
+
params = {}
|
46
|
+
|
47
|
+
else
|
48
|
+
path = Utils.__pathify( '_nodes', Utils.__listify(arguments[:node_id]), 'stats' )
|
49
|
+
|
50
|
+
params = arguments.select do |k,v|
|
51
|
+
[ :all,
|
52
|
+
:clear,
|
53
|
+
:fields,
|
54
|
+
:fs,
|
55
|
+
:http,
|
56
|
+
:indices,
|
57
|
+
:jvm,
|
58
|
+
:network,
|
59
|
+
:os,
|
60
|
+
:process,
|
61
|
+
:thread_pool,
|
62
|
+
:transport ].include?(k)
|
63
|
+
end
|
64
|
+
# Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
|
65
|
+
params = Hash[params] unless params.is_a?(Hash)
|
66
|
+
|
67
|
+
params[:fields] = Utils.__listify(params[:fields]) if params[:fields]
|
68
|
+
end
|
69
|
+
|
70
|
+
body = nil
|
71
|
+
|
72
|
+
perform_request(method, path, params, body).body
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Cluster
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Update cluster settings.
|
7
|
+
#
|
8
|
+
# @example Disable shard allocation in the cluster until restart
|
9
|
+
#
|
10
|
+
# client.cluster.put_settings body: { transient: { 'cluster.routing.allocation.disable_allocation' => true } }
|
11
|
+
#
|
12
|
+
# @option arguments [Hash] :body The settings to be updated. Can be either `transient` or `persistent`
|
13
|
+
# (survives cluster restart).
|
14
|
+
#
|
15
|
+
# @see http://elasticsearch.org/guide/reference/api/admin-cluster-update-settings/
|
16
|
+
#
|
17
|
+
def put_settings(arguments={})
|
18
|
+
method = 'PUT'
|
19
|
+
path = "_cluster/settings"
|
20
|
+
params = {}
|
21
|
+
body = arguments[:body] || {}
|
22
|
+
|
23
|
+
perform_request(method, path, params, body).body
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Cluster
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Perform manual shard allocation in the cluster.
|
7
|
+
#
|
8
|
+
# Pass the operations you want to perform in the `:body` option. Use the `dry_run` option to
|
9
|
+
# evaluate the result of operations without actually performing them.
|
10
|
+
#
|
11
|
+
# @example Move shard `0` of index `myindex` from node named _Node1_ to node named _Node2_
|
12
|
+
#
|
13
|
+
# client.cluster.reroute body: {
|
14
|
+
# commands: [
|
15
|
+
# { move: { index: 'myindex', shard: 0, from_node: 'Node1', to_node: 'Node2' } }
|
16
|
+
# ]
|
17
|
+
# }
|
18
|
+
#
|
19
|
+
# @note If you want to explicitely set the shard allocation to a certain node, you might
|
20
|
+
# want to look at the `allocation.*` cluster settings.
|
21
|
+
#
|
22
|
+
# @option arguments [Hash] :body The definition of `commands` to perform (`move`, `cancel`, `allocate`)
|
23
|
+
# @option arguments [Boolean] :dry_run Simulate the operation only and return the resulting state
|
24
|
+
# @option arguments [Boolean] :filter_metadata Don't return cluster state metadata (default: false)
|
25
|
+
#
|
26
|
+
# @see http://elasticsearch.org/guide/reference/api/admin-cluster-reroute/
|
27
|
+
#
|
28
|
+
def reroute(arguments={})
|
29
|
+
method = 'POST'
|
30
|
+
path = "_cluster/reroute"
|
31
|
+
params = arguments.select do |k,v|
|
32
|
+
[ :dry_run,
|
33
|
+
:filter_metadata ].include?(k)
|
34
|
+
end
|
35
|
+
# Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
|
36
|
+
params = Hash[params] unless params.is_a?(Hash)
|
37
|
+
body = arguments[:body] || {}
|
38
|
+
|
39
|
+
perform_request(method, path, params, body).body
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Cluster
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Get information about the cluster state (indices settings, allocations, etc)
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
#
|
10
|
+
# client.cluster.state
|
11
|
+
#
|
12
|
+
# @option arguments [Boolean] :filter_blocks Do not return information about blocks
|
13
|
+
# @option arguments [Boolean] :filter_index_templates Do not return information about index templates
|
14
|
+
# @option arguments [List] :filter_indices Limit returned metadata information to specific indices
|
15
|
+
# @option arguments [Boolean] :filter_metadata Do not return information about indices metadata
|
16
|
+
# @option arguments [Boolean] :filter_nodes Do not return information about nodes
|
17
|
+
# @option arguments [Boolean] :filter_routing_table Do not return information about shard allocation
|
18
|
+
# (`routing_table` and `routing_nodes`)
|
19
|
+
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
|
20
|
+
# (default: false)
|
21
|
+
# @option arguments [Time] :master_timeout Specify timeout for connection to master
|
22
|
+
#
|
23
|
+
# @see http://elasticsearch.org/guide/reference/api/admin-cluster-state/
|
24
|
+
#
|
25
|
+
def state(arguments={})
|
26
|
+
method = 'GET'
|
27
|
+
path = "_cluster/state"
|
28
|
+
params = arguments.select do |k,v|
|
29
|
+
[ :filter_blocks,
|
30
|
+
:filter_index_templates,
|
31
|
+
:filter_indices,
|
32
|
+
:filter_metadata,
|
33
|
+
:filter_nodes,
|
34
|
+
:filter_routing_table,
|
35
|
+
:local,
|
36
|
+
:master_timeout ].include?(k)
|
37
|
+
end
|
38
|
+
# Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
|
39
|
+
params = Hash[params] unless params.is_a?(Hash)
|
40
|
+
body = nil
|
41
|
+
|
42
|
+
perform_request(method, path, params, body).body
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Actions
|
4
|
+
|
5
|
+
# Get the number of documents for the cluster, index, type, or a query.
|
6
|
+
#
|
7
|
+
# @example Get the number of all documents in the cluster
|
8
|
+
#
|
9
|
+
# client.count
|
10
|
+
#
|
11
|
+
# @example Get the number of documents in a specified index
|
12
|
+
#
|
13
|
+
# client.count index: 'myindex'
|
14
|
+
#
|
15
|
+
# @option arguments [List] :index A comma-separated list of indices to restrict the results
|
16
|
+
# @option arguments [List] :type A comma-separated list of types to restrict the results
|
17
|
+
# @option arguments [Hash] :body A query to restrict the results (optional)
|
18
|
+
# @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore `missing` ones
|
19
|
+
# (options: none, missing)
|
20
|
+
# @option arguments [Number] :min_score Include only documents with a specific `_score` value in the result
|
21
|
+
# @option arguments [String] :preference Specify the node or shard the operation should be performed on
|
22
|
+
# (default: random)
|
23
|
+
# @option arguments [String] :routing Specific routing value
|
24
|
+
# @option arguments [String] :source The URL-encoded query definition (instead of using the request body)
|
25
|
+
#
|
26
|
+
# @see http://elasticsearch.org/guide/reference/api/count/
|
27
|
+
#
|
28
|
+
def count(arguments={})
|
29
|
+
method = 'GET'
|
30
|
+
path = Utils.__pathify( Utils.__listify(arguments[:index]), Utils.__listify(arguments[:type]), '_count' )
|
31
|
+
params = arguments.select do |k,v|
|
32
|
+
[ :ignore_indices,
|
33
|
+
:min_score,
|
34
|
+
:preference,
|
35
|
+
:routing,
|
36
|
+
:source ].include?(k)
|
37
|
+
end
|
38
|
+
# Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
|
39
|
+
params = Hash[params] unless params.is_a?(Hash)
|
40
|
+
body = arguments[:body]
|
41
|
+
|
42
|
+
perform_request(method, path, params, body).body
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|