elasticsearch-api 7.3.0 → 7.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +16 -23
- data/elasticsearch-api.gemspec +1 -1
- data/lib/elasticsearch/api/actions/abort_benchmark.rb +1 -2
- data/lib/elasticsearch/api/actions/benchmark.rb +2 -3
- data/lib/elasticsearch/api/actions/bulk.rb +35 -68
- data/lib/elasticsearch/api/actions/cat/aliases.rb +30 -52
- data/lib/elasticsearch/api/actions/cat/allocation.rb +36 -50
- data/lib/elasticsearch/api/actions/cat/count.rb +25 -46
- data/lib/elasticsearch/api/actions/cat/fielddata.rb +31 -33
- data/lib/elasticsearch/api/actions/cat/health.rb +27 -37
- data/lib/elasticsearch/api/actions/cat/help.rb +14 -10
- data/lib/elasticsearch/api/actions/cat/indices.rb +45 -62
- data/lib/elasticsearch/api/actions/cat/master.rb +24 -34
- data/lib/elasticsearch/api/actions/cat/nodeattrs.rb +20 -16
- data/lib/elasticsearch/api/actions/cat/nodes.rb +34 -46
- data/lib/elasticsearch/api/actions/cat/params_registry.rb +0 -1
- data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +29 -35
- data/lib/elasticsearch/api/actions/cat/plugins.rb +21 -18
- data/lib/elasticsearch/api/actions/cat/recovery.rb +40 -56
- data/lib/elasticsearch/api/actions/cat/repositories.rb +21 -24
- data/lib/elasticsearch/api/actions/cat/segments.rb +29 -22
- data/lib/elasticsearch/api/actions/cat/shards.rb +38 -59
- data/lib/elasticsearch/api/actions/cat/snapshots.rb +32 -27
- data/lib/elasticsearch/api/actions/cat/tasks.rb +25 -19
- data/lib/elasticsearch/api/actions/cat/templates.rb +26 -18
- data/lib/elasticsearch/api/actions/cat/thread_pool.rb +36 -46
- data/lib/elasticsearch/api/actions/clear_scroll.rb +21 -8
- data/lib/elasticsearch/api/actions/cluster/allocation_explain.rb +15 -13
- data/lib/elasticsearch/api/actions/cluster/get_settings.rb +18 -18
- data/lib/elasticsearch/api/actions/cluster/health.rb +42 -44
- data/lib/elasticsearch/api/actions/cluster/params_registry.rb +0 -1
- data/lib/elasticsearch/api/actions/cluster/pending_tasks.rb +15 -17
- data/lib/elasticsearch/api/actions/cluster/put_settings.rb +20 -17
- data/lib/elasticsearch/api/actions/cluster/remote_info.rb +8 -6
- data/lib/elasticsearch/api/actions/cluster/reroute.rb +25 -37
- data/lib/elasticsearch/api/actions/cluster/state.rb +37 -41
- data/lib/elasticsearch/api/actions/cluster/stats.rb +20 -12
- data/lib/elasticsearch/api/actions/count.rb +52 -39
- data/lib/elasticsearch/api/actions/create.rb +25 -26
- data/lib/elasticsearch/api/actions/delete.rb +43 -36
- data/lib/elasticsearch/api/actions/delete_by_query.rb +74 -62
- data/lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb +39 -0
- data/lib/elasticsearch/api/actions/delete_by_rethrottle.rb +4 -3
- data/lib/elasticsearch/api/actions/delete_script.rb +19 -13
- data/lib/elasticsearch/api/actions/exists.rb +44 -34
- data/lib/elasticsearch/api/actions/exists_source.rb +43 -25
- data/lib/elasticsearch/api/actions/explain.rb +46 -51
- data/lib/elasticsearch/api/actions/field_caps.rb +27 -20
- data/lib/elasticsearch/api/actions/get.rb +42 -41
- data/lib/elasticsearch/api/actions/get_script.rb +19 -14
- data/lib/elasticsearch/api/actions/get_source.rb +38 -44
- data/lib/elasticsearch/api/actions/index.rb +60 -89
- data/lib/elasticsearch/api/actions/indices/analyze.rb +19 -48
- data/lib/elasticsearch/api/actions/indices/clear_cache.rb +29 -41
- data/lib/elasticsearch/api/actions/indices/clone.rb +50 -0
- data/lib/elasticsearch/api/actions/indices/close.rb +28 -32
- data/lib/elasticsearch/api/actions/indices/create.rb +22 -70
- data/lib/elasticsearch/api/actions/indices/delete.rb +23 -35
- data/lib/elasticsearch/api/actions/indices/delete_alias.rb +24 -20
- data/lib/elasticsearch/api/actions/indices/delete_template.rb +18 -20
- data/lib/elasticsearch/api/actions/indices/exists.rb +32 -34
- data/lib/elasticsearch/api/actions/indices/exists_alias.rb +33 -29
- data/lib/elasticsearch/api/actions/indices/exists_template.rb +21 -16
- data/lib/elasticsearch/api/actions/indices/exists_type.rb +29 -29
- data/lib/elasticsearch/api/actions/indices/flush.rb +28 -28
- data/lib/elasticsearch/api/actions/indices/flush_synced.rb +23 -12
- data/lib/elasticsearch/api/actions/indices/forcemerge.rb +26 -41
- data/lib/elasticsearch/api/actions/indices/freeze.rb +7 -8
- data/lib/elasticsearch/api/actions/indices/get.rb +25 -19
- data/lib/elasticsearch/api/actions/indices/get_alias.rb +31 -23
- data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +42 -38
- data/lib/elasticsearch/api/actions/indices/get_mapping.rb +39 -31
- data/lib/elasticsearch/api/actions/indices/get_settings.rb +34 -37
- data/lib/elasticsearch/api/actions/indices/get_template.rb +21 -23
- data/lib/elasticsearch/api/actions/indices/get_upgrade.rb +48 -0
- data/lib/elasticsearch/api/actions/indices/open.rb +24 -21
- data/lib/elasticsearch/api/actions/indices/params_registry.rb +0 -1
- data/lib/elasticsearch/api/actions/indices/put_alias.rb +25 -27
- data/lib/elasticsearch/api/actions/indices/put_mapping.rb +40 -39
- data/lib/elasticsearch/api/actions/indices/put_settings.rb +30 -37
- data/lib/elasticsearch/api/actions/indices/put_template.rb +23 -23
- data/lib/elasticsearch/api/actions/indices/recovery.rb +20 -23
- data/lib/elasticsearch/api/actions/indices/refresh.rb +22 -26
- data/lib/elasticsearch/api/actions/indices/rollover.rb +28 -19
- data/lib/elasticsearch/api/actions/indices/segments.rb +24 -17
- data/lib/elasticsearch/api/actions/indices/shard_stores.rb +27 -15
- data/lib/elasticsearch/api/actions/indices/shrink.rb +23 -17
- data/lib/elasticsearch/api/actions/indices/split.rb +23 -17
- data/lib/elasticsearch/api/actions/indices/stats.rb +53 -104
- data/lib/elasticsearch/api/actions/indices/unfreeze.rb +7 -7
- data/lib/elasticsearch/api/actions/indices/update_aliases.rb +15 -32
- data/lib/elasticsearch/api/actions/indices/upgrade.rb +26 -16
- data/lib/elasticsearch/api/actions/indices/validate_query.rb +46 -59
- data/lib/elasticsearch/api/actions/info.rb +9 -6
- data/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb +18 -12
- data/lib/elasticsearch/api/actions/ingest/get_pipeline.rb +21 -11
- data/lib/elasticsearch/api/actions/ingest/params_registry.rb +0 -1
- data/lib/elasticsearch/api/actions/ingest/processor_grok.rb +12 -13
- data/lib/elasticsearch/api/actions/ingest/put_pipeline.rb +19 -14
- data/lib/elasticsearch/api/actions/ingest/simulate.rb +23 -13
- data/lib/elasticsearch/api/actions/mget.rb +37 -44
- data/lib/elasticsearch/api/actions/msearch.rb +54 -54
- data/lib/elasticsearch/api/actions/msearch_template.rb +46 -35
- data/lib/elasticsearch/api/actions/mtermvectors.rb +39 -35
- data/lib/elasticsearch/api/actions/nodes/hot_threads.rb +30 -25
- data/lib/elasticsearch/api/actions/nodes/info.rb +29 -63
- data/lib/elasticsearch/api/actions/nodes/params_registry.rb +0 -1
- data/lib/elasticsearch/api/actions/nodes/reload_secure_settings.rb +24 -22
- data/lib/elasticsearch/api/actions/nodes/shutdown.rb +4 -4
- data/lib/elasticsearch/api/actions/nodes/stats.rb +43 -36
- data/lib/elasticsearch/api/actions/nodes/usage.rb +31 -10
- data/lib/elasticsearch/api/actions/params_registry.rb +0 -1
- data/lib/elasticsearch/api/actions/ping.rb +12 -13
- data/lib/elasticsearch/api/actions/put_script.rb +26 -30
- data/lib/elasticsearch/api/actions/rank_eval.rb +24 -15
- data/lib/elasticsearch/api/actions/reindex.rb +25 -48
- data/lib/elasticsearch/api/actions/reindex_rethrottle.rb +18 -12
- data/lib/elasticsearch/api/actions/remote/info.rb +1 -2
- data/lib/elasticsearch/api/actions/render_search_template.rb +17 -15
- data/lib/elasticsearch/api/actions/scripts_painless_execute.rb +8 -6
- data/lib/elasticsearch/api/actions/scroll.rb +28 -51
- data/lib/elasticsearch/api/actions/search.rb +104 -165
- data/lib/elasticsearch/api/actions/search_shards.rb +31 -28
- data/lib/elasticsearch/api/actions/search_template.rb +48 -40
- data/lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb +44 -0
- data/lib/elasticsearch/api/actions/snapshot/create.rb +22 -29
- data/lib/elasticsearch/api/actions/snapshot/create_repository.rb +19 -24
- data/lib/elasticsearch/api/actions/snapshot/delete.rb +20 -22
- data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +16 -18
- data/lib/elasticsearch/api/actions/snapshot/get.rb +22 -31
- data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +21 -25
- data/lib/elasticsearch/api/actions/snapshot/params_registry.rb +0 -1
- data/lib/elasticsearch/api/actions/snapshot/restore.rb +21 -32
- data/lib/elasticsearch/api/actions/snapshot/status.rb +23 -24
- data/lib/elasticsearch/api/actions/snapshot/verify_repository.rb +18 -13
- data/lib/elasticsearch/api/actions/tasks/cancel.rb +19 -13
- data/lib/elasticsearch/api/actions/tasks/get.rb +16 -13
- data/lib/elasticsearch/api/actions/tasks/list.rb +20 -18
- data/lib/elasticsearch/api/actions/tasks/params_registry.rb +0 -1
- data/lib/elasticsearch/api/actions/termvectors.rb +52 -70
- data/lib/elasticsearch/api/actions/update.rb +53 -98
- data/lib/elasticsearch/api/actions/update_by_query.rb +77 -66
- data/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb +17 -11
- data/lib/elasticsearch/api/version.rb +1 -1
- data/spec/elasticsearch/api/actions/cat/segments_spec.rb +9 -11
- data/spec/elasticsearch/api/actions/cluster/put_settings_spec.rb +1 -1
- data/spec/elasticsearch/api/actions/count_spec.rb +8 -8
- data/spec/elasticsearch/api/actions/delete_by_query_spec.rb +12 -7
- data/spec/elasticsearch/api/actions/delete_script_spec.rb +0 -14
- data/spec/elasticsearch/api/actions/exists_document_spec.rb +1 -1
- data/spec/elasticsearch/api/actions/get_document_source_spec.rb +1 -1
- data/spec/elasticsearch/api/actions/index_document_spec.rb +6 -15
- data/spec/elasticsearch/api/actions/indices/analyze_spec.rb +0 -4
- data/spec/elasticsearch/api/actions/indices/clear_cache_spec.rb +1 -5
- data/spec/elasticsearch/api/actions/indices/clone_spec.rb +109 -0
- data/spec/elasticsearch/api/actions/indices/delete_alias_spec.rb +2 -2
- data/spec/elasticsearch/api/actions/indices/get_spec.rb +0 -11
- data/spec/elasticsearch/api/actions/indices/put_alias_spec.rb +3 -3
- data/spec/elasticsearch/api/actions/indices/put_mapping_spec.rb +3 -3
- data/spec/elasticsearch/api/actions/indices/stats_spec.rb +0 -1
- data/spec/elasticsearch/api/actions/nodes/hot_threads_spec.rb +3 -3
- data/spec/elasticsearch/api/actions/put_script_spec.rb +20 -15
- data/spec/elasticsearch/api/actions/render_search_template_spec.rb +23 -7
- data/spec/elasticsearch/api/actions/scroll_spec.rb +37 -0
- data/spec/elasticsearch/api/actions/search_spec.rb +0 -15
- data/spec/elasticsearch/api/actions/tasks/list_spec.rb +0 -11
- data/spec/elasticsearch/api/actions/update_document_spec.rb +3 -7
- data/spec/elasticsearch/api/rest_api_yaml_spec.rb +1 -1
- data/spec/rest_yaml_tests_helper.rb +12 -0
- data/utils/Gemfile +1 -0
- data/utils/Thorfile +0 -1
- data/utils/thor/generate_source.rb +192 -85
- data/utils/thor/generator/endpoint_specifics.rb +157 -0
- data/utils/thor/generator/files_helper.rb +37 -0
- data/utils/thor/lister.rb +3 -4
- data/utils/thor/templates/_documentation_top.erb +27 -0
- data/utils/thor/templates/_method_setup.erb +35 -0
- data/utils/thor/templates/_params_registry.erb +12 -0
- data/utils/thor/templates/_perform_request.erb +37 -0
- data/utils/thor/templates/method.erb +59 -0
- data/utils/thor/templates/{ruby/test.erb → test.erb} +0 -0
- data/utils/thor/templates/{ruby/test_helper.rb → test_helper.rb} +0 -0
- metadata +31 -14
- data/spec/elasticsearch/api/actions/scoll_spec.rb +0 -21
- data/utils/thor/generate_api.rb +0 -193
- data/utils/thor/templates/ruby/method.erb +0 -62
@@ -6,56 +6,44 @@ module Elasticsearch
|
|
6
6
|
module API
|
7
7
|
module Cluster
|
8
8
|
module Actions
|
9
|
-
|
10
|
-
# Perform manual shard allocation in the cluster.
|
11
|
-
#
|
12
|
-
# Pass the operations you want to perform in the `:body` option. Use the `dry_run` option to
|
13
|
-
# evaluate the result of operations without actually performing them.
|
14
|
-
#
|
15
|
-
# @example Move shard `0` of index `myindex` from node named _Node1_ to node named _Node2_
|
9
|
+
# Allows to manually change the allocation of individual shards in the cluster.
|
16
10
|
#
|
17
|
-
# client.cluster.reroute body: {
|
18
|
-
# commands: [
|
19
|
-
# { move: { index: 'myindex', shard: 0, from_node: 'Node1', to_node: 'Node2' } }
|
20
|
-
# ]
|
21
|
-
# }
|
22
|
-
#
|
23
|
-
# @note If you want to explicitly set the shard allocation to a certain node, you might
|
24
|
-
# want to look at the `allocation.*` cluster settings.
|
25
|
-
#
|
26
|
-
# @option arguments [Hash] :body The definition of `commands` to perform (`move`, `cancel`, `allocate`)
|
27
11
|
# @option arguments [Boolean] :dry_run Simulate the operation only and return the resulting state
|
28
|
-
# @option arguments [Boolean] :explain Return an explanation
|
29
|
-
# @option arguments [Boolean] :
|
30
|
-
#
|
31
|
-
#
|
32
|
-
|
33
|
-
# @option arguments [
|
34
|
-
#
|
12
|
+
# @option arguments [Boolean] :explain Return an explanation of why the commands can or cannot be executed
|
13
|
+
# @option arguments [Boolean] :retry_failed Retries allocation of shards that are blocked due to too many subsequent allocation failures
|
14
|
+
# @option arguments [List] :metric Limit the information returned to the specified metrics. Defaults to all but metadata
|
15
|
+
# (options: _all,blocks,metadata,nodes,routing_table,master_node,version)
|
16
|
+
|
17
|
+
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
|
18
|
+
# @option arguments [Time] :timeout Explicit operation timeout
|
19
|
+
|
20
|
+
# @option arguments [Hash] :body The definition of `commands` to perform (`move`, `cancel`, `allocate`)
|
35
21
|
#
|
36
|
-
# @see
|
22
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/cluster-reroute.html
|
37
23
|
#
|
38
|
-
def reroute(arguments={})
|
39
|
-
|
40
|
-
path = "_cluster/reroute"
|
24
|
+
def reroute(arguments = {})
|
25
|
+
arguments = arguments.clone
|
41
26
|
|
27
|
+
method = Elasticsearch::API::HTTP_POST
|
28
|
+
path = "_cluster/reroute"
|
42
29
|
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
43
|
-
body = arguments[:body] || {}
|
44
30
|
|
31
|
+
body = arguments[:body] || {}
|
45
32
|
perform_request(method, path, params, body).body
|
46
33
|
end
|
47
34
|
|
48
35
|
# Register this action with its valid params when the module is loaded.
|
49
36
|
#
|
50
|
-
# @since 6.
|
37
|
+
# @since 6.2.0
|
51
38
|
ParamsRegistry.register(:reroute, [
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
39
|
+
:dry_run,
|
40
|
+
:explain,
|
41
|
+
:retry_failed,
|
42
|
+
:metric,
|
43
|
+
:master_timeout,
|
44
|
+
:timeout
|
45
|
+
].freeze)
|
46
|
+
end
|
58
47
|
end
|
59
|
-
end
|
60
48
|
end
|
61
49
|
end
|
@@ -6,64 +6,60 @@ module Elasticsearch
|
|
6
6
|
module API
|
7
7
|
module Cluster
|
8
8
|
module Actions
|
9
|
-
|
10
|
-
# Get information about the cluster state (indices settings, allocations, etc)
|
11
|
-
#
|
12
|
-
# @example
|
13
|
-
#
|
14
|
-
# client.cluster.state
|
9
|
+
# Returns a comprehensive information about the state of the cluster.
|
15
10
|
#
|
16
|
-
# @option arguments [List] :index A comma-separated list of index names; use `_all` or omit to
|
17
|
-
# perform the operation on all indices
|
18
11
|
# @option arguments [List] :metric Limit the information returned to the specified metrics
|
19
|
-
#
|
20
|
-
|
21
|
-
# @option arguments [List] :
|
22
|
-
#
|
23
|
-
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
|
24
|
-
# (default: false)
|
12
|
+
# (options: _all,blocks,metadata,nodes,routing_table,routing_nodes,master_node,version)
|
13
|
+
|
14
|
+
# @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
|
15
|
+
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false)
|
25
16
|
# @option arguments [Time] :master_timeout Specify timeout for connection to master
|
26
|
-
# @option arguments [
|
27
|
-
#
|
17
|
+
# @option arguments [Boolean] :flat_settings Return settings in flat format (default: false)
|
18
|
+
# @option arguments [Number] :wait_for_metadata_version Wait for the metadata version to be equal or greater than the specified metadata version
|
19
|
+
# @option arguments [Time] :wait_for_timeout The maximum time to wait for wait_for_metadata_version before timing out
|
20
|
+
# @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
28
21
|
# @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)
|
29
|
-
# @option arguments [
|
30
|
-
#
|
22
|
+
# @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
23
|
+
# (options: open,closed,none,all)
|
24
|
+
|
31
25
|
#
|
32
|
-
# @see
|
26
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/cluster-state.html
|
33
27
|
#
|
34
|
-
def state(arguments={})
|
28
|
+
def state(arguments = {})
|
35
29
|
arguments = arguments.clone
|
36
|
-
index = arguments.delete(:index)
|
37
|
-
metric = arguments.delete(:metric)
|
38
|
-
method = HTTP_GET
|
39
|
-
path = Utils.__pathify '_cluster/state',
|
40
|
-
Utils.__listify(metric),
|
41
|
-
Utils.__listify(index)
|
42
30
|
|
43
|
-
|
31
|
+
_metric = arguments.delete(:metric)
|
44
32
|
|
45
|
-
|
46
|
-
params[key] = Utils.__listify(params[key]) if params[key]
|
47
|
-
end
|
33
|
+
_index = arguments.delete(:index)
|
48
34
|
|
49
|
-
|
35
|
+
method = Elasticsearch::API::HTTP_GET
|
36
|
+
path = if _metric && _index
|
37
|
+
"_cluster/state/#{Utils.__listify(_metric)}/#{Utils.__listify(_index)}"
|
38
|
+
elsif _metric
|
39
|
+
"_cluster/state/#{Utils.__listify(_metric)}"
|
40
|
+
else
|
41
|
+
"_cluster/state"
|
42
|
+
end
|
43
|
+
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
50
44
|
|
45
|
+
body = nil
|
51
46
|
perform_request(method, path, params, body).body
|
52
47
|
end
|
53
48
|
|
54
49
|
# Register this action with its valid params when the module is loaded.
|
55
50
|
#
|
56
|
-
# @since 6.
|
51
|
+
# @since 6.2.0
|
57
52
|
ParamsRegistry.register(:state, [
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
53
|
+
:local,
|
54
|
+
:master_timeout,
|
55
|
+
:flat_settings,
|
56
|
+
:wait_for_metadata_version,
|
57
|
+
:wait_for_timeout,
|
58
|
+
:ignore_unavailable,
|
59
|
+
:allow_no_indices,
|
60
|
+
:expand_wildcards
|
61
|
+
].freeze)
|
62
|
+
end
|
66
63
|
end
|
67
|
-
end
|
68
64
|
end
|
69
65
|
end
|
@@ -6,32 +6,40 @@ module Elasticsearch
|
|
6
6
|
module API
|
7
7
|
module Cluster
|
8
8
|
module Actions
|
9
|
-
|
10
|
-
# Returns statistical information about the cluster
|
9
|
+
# Returns high-level overview of cluster statistics.
|
11
10
|
#
|
12
11
|
# @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
|
13
12
|
# @option arguments [Boolean] :flat_settings Return settings in flat format (default: false)
|
14
|
-
# @option arguments [Boolean] :human Whether to return time and byte values in human-readable format.
|
15
13
|
# @option arguments [Time] :timeout Explicit operation timeout
|
14
|
+
|
16
15
|
#
|
17
|
-
# @see
|
16
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/cluster-stats.html
|
18
17
|
#
|
19
|
-
def stats(arguments={})
|
20
|
-
|
21
|
-
|
18
|
+
def stats(arguments = {})
|
19
|
+
arguments = arguments.clone
|
20
|
+
|
21
|
+
_node_id = arguments.delete(:node_id)
|
22
|
+
|
23
|
+
method = Elasticsearch::API::HTTP_GET
|
24
|
+
path = if _node_id
|
25
|
+
"_cluster/stats/nodes/#{Utils.__listify(_node_id)}"
|
26
|
+
else
|
27
|
+
"_cluster/stats"
|
28
|
+
end
|
22
29
|
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
23
|
-
body = nil
|
24
30
|
|
31
|
+
body = nil
|
25
32
|
perform_request(method, path, params, body).body
|
26
33
|
end
|
27
34
|
|
28
35
|
# Register this action with its valid params when the module is loaded.
|
29
36
|
#
|
30
|
-
# @since 6.
|
37
|
+
# @since 6.2.0
|
31
38
|
ParamsRegistry.register(:stats, [
|
32
|
-
|
33
|
-
|
39
|
+
:flat_settings,
|
40
|
+
:timeout
|
41
|
+
].freeze)
|
42
|
+
end
|
34
43
|
end
|
35
|
-
end
|
36
44
|
end
|
37
45
|
end
|
@@ -5,70 +5,83 @@
|
|
5
5
|
module Elasticsearch
|
6
6
|
module API
|
7
7
|
module Actions
|
8
|
-
|
9
|
-
# Get the number of documents for the cluster, index, type, or a query.
|
10
|
-
#
|
11
|
-
# @example Get the number of all documents in the cluster
|
12
|
-
#
|
13
|
-
# client.count
|
14
|
-
#
|
15
|
-
# @example Get the number of documents in a specified index
|
16
|
-
#
|
17
|
-
# client.count index: 'myindex'
|
18
|
-
#
|
19
|
-
# @example Get the number of documents matching a specific query
|
20
|
-
#
|
21
|
-
# index: 'my_index', body: { filtered: { filter: { terms: { foo: ['bar'] } } } }
|
22
|
-
#
|
8
|
+
# Returns number of documents matching a query.
|
23
9
|
#
|
24
10
|
# @option arguments [List] :index A comma-separated list of indices to restrict the results
|
25
11
|
# @option arguments [List] :type A comma-separated list of types to restrict the results
|
26
|
-
# @option arguments [Hash] :body A query to restrict the results specified with the Query DSL (optional)
|
27
12
|
# @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
28
13
|
# @option arguments [Boolean] :ignore_throttled Whether specified concrete, expanded or aliased indices should be ignored when throttled
|
29
14
|
# @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)
|
30
|
-
# @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
15
|
+
# @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
16
|
+
# (options: open,closed,none,all)
|
17
|
+
|
31
18
|
# @option arguments [Number] :min_score Include only documents with a specific `_score` value in the result
|
32
19
|
# @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
|
33
20
|
# @option arguments [List] :routing A comma-separated list of specific routing values
|
34
21
|
# @option arguments [String] :q Query in the Lucene query string syntax
|
35
22
|
# @option arguments [String] :analyzer The analyzer to use for the query string
|
36
23
|
# @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false)
|
37
|
-
# @option arguments [String] :default_operator The default operator for query string query (AND or OR)
|
24
|
+
# @option arguments [String] :default_operator The default operator for query string query (AND or OR)
|
25
|
+
# (options: AND,OR)
|
26
|
+
|
38
27
|
# @option arguments [String] :df The field to use as default where no field prefix is given in the query string
|
39
28
|
# @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
|
40
29
|
# @option arguments [Number] :terminate_after The maximum count for each shard, upon reaching which the query execution will terminate early
|
30
|
+
|
31
|
+
# @option arguments [Hash] :body A query to restrict the results specified with the Query DSL (optional)
|
32
|
+
#
|
33
|
+
# *Deprecation notice*:
|
34
|
+
# Specifying types in urls has been deprecated
|
35
|
+
# Deprecated since version 7.0.0
|
41
36
|
#
|
42
|
-
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html
|
43
37
|
#
|
44
|
-
|
45
|
-
|
46
|
-
|
38
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-count.html
|
39
|
+
#
|
40
|
+
def count(arguments = {})
|
41
|
+
arguments = arguments.clone
|
42
|
+
|
43
|
+
_index = arguments.delete(:index)
|
47
44
|
|
45
|
+
_type = arguments.delete(:type)
|
46
|
+
|
47
|
+
method = if arguments[:body]
|
48
|
+
Elasticsearch::API::HTTP_POST
|
49
|
+
else
|
50
|
+
Elasticsearch::API::HTTP_GET
|
51
|
+
end
|
52
|
+
|
53
|
+
path = if _index && _type
|
54
|
+
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_count"
|
55
|
+
elsif _index
|
56
|
+
"#{Utils.__listify(_index)}/_count"
|
57
|
+
else
|
58
|
+
"_count"
|
59
|
+
end
|
48
60
|
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
49
|
-
body = arguments[:body]
|
50
61
|
|
62
|
+
body = arguments[:body]
|
51
63
|
perform_request(method, path, params, body).body
|
52
64
|
end
|
53
65
|
|
54
66
|
# Register this action with its valid params when the module is loaded.
|
55
67
|
#
|
56
|
-
# @since 6.
|
68
|
+
# @since 6.2.0
|
57
69
|
ParamsRegistry.register(:count, [
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
70
|
+
:ignore_unavailable,
|
71
|
+
:ignore_throttled,
|
72
|
+
:allow_no_indices,
|
73
|
+
:expand_wildcards,
|
74
|
+
:min_score,
|
75
|
+
:preference,
|
76
|
+
:routing,
|
77
|
+
:q,
|
78
|
+
:analyzer,
|
79
|
+
:analyze_wildcard,
|
80
|
+
:default_operator,
|
81
|
+
:df,
|
82
|
+
:lenient,
|
83
|
+
:terminate_after
|
84
|
+
].freeze)
|
85
|
+
end
|
72
86
|
end
|
73
|
-
end
|
74
87
|
end
|
@@ -5,42 +5,41 @@
|
|
5
5
|
module Elasticsearch
|
6
6
|
module API
|
7
7
|
module Actions
|
8
|
-
|
9
|
-
# Create a new document.
|
10
|
-
#
|
11
|
-
# The API will create new document, if it doesn't exist yet -- in that case, it will return
|
12
|
-
# a `409` error (`version_conflict_engine_exception`).
|
13
|
-
#
|
14
|
-
# You can leave out the `:id` parameter for the ID to be generated automatically
|
15
|
-
#
|
16
|
-
# @example Create a document with an ID
|
8
|
+
# Creates a new document in the index.
|
17
9
|
#
|
18
|
-
#
|
19
|
-
# type: 'doc',
|
20
|
-
# id: '1',
|
21
|
-
# body: {
|
22
|
-
# title: 'Test 1'
|
23
|
-
# }
|
10
|
+
# Returns a 409 response when a document with a same ID already exists in the index.
|
24
11
|
#
|
25
|
-
# @
|
12
|
+
# @option arguments [String] :id Document ID
|
13
|
+
# @option arguments [String] :index The name of the index
|
14
|
+
# @option arguments [String] :type The type of the document *Deprecated*
|
15
|
+
# @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
|
16
|
+
# @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
|
17
|
+
# (options: true,false,wait_for)
|
18
|
+
|
19
|
+
# @option arguments [String] :routing Specific routing value
|
20
|
+
# @option arguments [Time] :timeout Explicit operation timeout
|
21
|
+
# @option arguments [Number] :version Explicit version number for concurrency control
|
22
|
+
# @option arguments [String] :version_type Specific version type
|
23
|
+
# (options: internal,external,external_gte)
|
24
|
+
|
25
|
+
# @option arguments [String] :pipeline The pipeline id to preprocess incoming documents with
|
26
|
+
|
27
|
+
# @option arguments [Hash] :body The document (*Required*)
|
26
28
|
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
# title: 'Test 1'
|
31
|
-
# }
|
29
|
+
# *Deprecation notice*:
|
30
|
+
# Specifying types in urls has been deprecated
|
31
|
+
# Deprecated since version 7.0.0
|
32
32
|
#
|
33
|
-
# @option (see Actions#index)
|
34
33
|
#
|
35
|
-
# @see https://www.elastic.co/guide/en/elasticsearch/reference/
|
34
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-index_.html
|
36
35
|
#
|
37
|
-
def create(arguments={})
|
36
|
+
def create(arguments = {})
|
38
37
|
if arguments[:id]
|
39
|
-
index arguments.update :
|
38
|
+
index arguments.update op_type: 'create'
|
40
39
|
else
|
41
40
|
index arguments
|
42
41
|
end
|
43
42
|
end
|
44
43
|
end
|
45
|
-
|
44
|
+
end
|
46
45
|
end
|
@@ -5,45 +5,52 @@
|
|
5
5
|
module Elasticsearch
|
6
6
|
module API
|
7
7
|
module Actions
|
8
|
-
|
9
|
-
# Delete a single document.
|
10
|
-
#
|
11
|
-
# @example Delete a document
|
12
|
-
#
|
13
|
-
# client.delete index: 'myindex', type: 'mytype', id: '1'
|
14
|
-
#
|
15
|
-
# @example Delete a document with specific routing
|
8
|
+
# Removes a document from the index.
|
16
9
|
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
# @option arguments [String] :
|
20
|
-
# @option arguments [String] :index The name of the index (*Required*)
|
21
|
-
# @option arguments [String] :type The type of the document
|
10
|
+
# @option arguments [String] :id The document ID
|
11
|
+
# @option arguments [String] :index The name of the index
|
12
|
+
# @option arguments [String] :type The type of the document *Deprecated*
|
22
13
|
# @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
|
23
|
-
# @option arguments [String] :
|
24
|
-
#
|
14
|
+
# @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
|
15
|
+
# (options: true,false,wait_for)
|
16
|
+
|
25
17
|
# @option arguments [String] :routing Specific routing value
|
26
18
|
# @option arguments [Time] :timeout Explicit operation timeout
|
27
19
|
# @option arguments [Number] :if_seq_no only perform the delete operation if the last operation that has changed the document has the specified sequence number
|
28
20
|
# @option arguments [Number] :if_primary_term only perform the delete operation if the last operation that has changed the document has the specified primary term
|
29
21
|
# @option arguments [Number] :version Explicit version number for concurrency control
|
30
|
-
# @option arguments [String] :version_type Specific version type
|
22
|
+
# @option arguments [String] :version_type Specific version type
|
23
|
+
# (options: internal,external,external_gte,force)
|
24
|
+
|
25
|
+
#
|
26
|
+
# *Deprecation notice*:
|
27
|
+
# Specifying types in urls has been deprecated
|
28
|
+
# Deprecated since version 7.0.0
|
31
29
|
#
|
32
|
-
# @see http://elasticsearch.org/guide/reference/api/delete/
|
33
30
|
#
|
34
|
-
|
31
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-delete.html
|
32
|
+
#
|
33
|
+
def delete(arguments = {})
|
35
34
|
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
|
36
|
-
raise ArgumentError, "Required argument 'id' missing"
|
37
|
-
|
35
|
+
raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
|
36
|
+
|
37
|
+
arguments = arguments.clone
|
38
|
+
|
39
|
+
_id = arguments.delete(:id)
|
40
|
+
|
41
|
+
_index = arguments.delete(:index)
|
38
42
|
|
39
|
-
|
40
|
-
path = Utils.__pathify Utils.__escape(arguments[:index]),
|
41
|
-
Utils.__escape(arguments[:type]),
|
42
|
-
Utils.__escape(arguments[:id])
|
43
|
+
_type = arguments.delete(:type)
|
43
44
|
|
45
|
+
method = Elasticsearch::API::HTTP_DELETE
|
46
|
+
path = if _index && _type && _id
|
47
|
+
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}"
|
48
|
+
else
|
49
|
+
"#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
|
50
|
+
end
|
44
51
|
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
45
|
-
body = nil
|
46
52
|
|
53
|
+
body = nil
|
47
54
|
if Array(arguments[:ignore]).include?(404)
|
48
55
|
Utils.__rescue_from_not_found { perform_request(method, path, params, body).body }
|
49
56
|
else
|
@@ -53,17 +60,17 @@ module Elasticsearch
|
|
53
60
|
|
54
61
|
# Register this action with its valid params when the module is loaded.
|
55
62
|
#
|
56
|
-
# @since 6.
|
63
|
+
# @since 6.2.0
|
57
64
|
ParamsRegistry.register(:delete, [
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
65
|
+
:wait_for_active_shards,
|
66
|
+
:refresh,
|
67
|
+
:routing,
|
68
|
+
:timeout,
|
69
|
+
:if_seq_no,
|
70
|
+
:if_primary_term,
|
71
|
+
:version,
|
72
|
+
:version_type
|
73
|
+
].freeze)
|
74
|
+
end
|
67
75
|
end
|
68
|
-
end
|
69
76
|
end
|