elasticsearch-api 7.4.0 → 7.5.0.pre.pre
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/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 +21 -21
- 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 +1 -1
- 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/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 +19 -11
- 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
@@ -5,81 +5,76 @@
|
|
5
5
|
module Elasticsearch
|
6
6
|
module API
|
7
7
|
module Actions
|
8
|
-
|
9
|
-
# Return information if and how well a document matches a query.
|
10
|
-
#
|
11
|
-
# The returned information contains a `_score` and its explanation, if the document matches the query.
|
12
|
-
#
|
13
|
-
# @example Passing the query in the Lucene query syntax as the `:q` URL parameter
|
14
|
-
#
|
15
|
-
# client.explain index: 'myindex', type: 'mytype', id: '1', q: 'test'
|
16
|
-
#
|
17
|
-
# @example Passing the query in the Query DSL as the request `:body`
|
8
|
+
# Returns information about why a specific matches (or doesn't match) a query.
|
18
9
|
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
# @option arguments [String] :id The document ID (*Required*)
|
23
|
-
# @option arguments [String] :index The name of the index (*Required*)
|
24
|
-
# @option arguments [String] :type The type of the document
|
25
|
-
# @option arguments [Hash] :body The query definition using the Query DSL
|
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*
|
26
13
|
# @option arguments [Boolean] :analyze_wildcard Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false)
|
27
14
|
# @option arguments [String] :analyzer The analyzer for the query string query
|
28
|
-
# @option arguments [String] :default_operator The default operator for query string query (AND or OR)
|
15
|
+
# @option arguments [String] :default_operator The default operator for query string query (AND or OR)
|
16
|
+
# (options: AND,OR)
|
17
|
+
|
29
18
|
# @option arguments [String] :df The default field for query string query (default: _all)
|
30
19
|
# @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response
|
31
20
|
# @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
|
32
|
-
# @option arguments [String] :parent The ID of the parent document
|
33
21
|
# @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
|
34
22
|
# @option arguments [String] :q Query in the Lucene query string syntax
|
35
23
|
# @option arguments [String] :routing Specific routing value
|
36
24
|
# @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return
|
37
25
|
# @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field
|
38
26
|
# @option arguments [List] :_source_includes A list of fields to extract and return from the _source field
|
27
|
+
|
28
|
+
# @option arguments [Hash] :body The query definition using the Query DSL
|
39
29
|
#
|
40
|
-
#
|
30
|
+
# *Deprecation notice*:
|
31
|
+
# Specifying types in urls has been deprecated
|
32
|
+
# Deprecated since version 7.0.0
|
41
33
|
#
|
42
|
-
|
34
|
+
#
|
35
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-explain.html
|
36
|
+
#
|
37
|
+
def explain(arguments = {})
|
43
38
|
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
|
44
|
-
raise ArgumentError, "Required argument 'id' missing"
|
45
|
-
method = HTTP_GET
|
39
|
+
raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
|
46
40
|
|
47
|
-
|
48
|
-
path = Utils.__pathify Utils.__escape(arguments[:index]),
|
49
|
-
Utils.__escape(arguments[:type]),
|
50
|
-
Utils.__escape(arguments[:id]),
|
51
|
-
'_explain'
|
52
|
-
else
|
53
|
-
path = Utils.__pathify Utils.__escape(arguments[:index]),
|
54
|
-
'_explain',
|
55
|
-
Utils.__escape(arguments[:id])
|
56
|
-
end
|
41
|
+
arguments = arguments.clone
|
57
42
|
|
58
|
-
|
59
|
-
body = arguments[:body]
|
43
|
+
_id = arguments.delete(:id)
|
60
44
|
|
61
|
-
|
45
|
+
_index = arguments.delete(:index)
|
62
46
|
|
47
|
+
_type = arguments.delete(:type)
|
48
|
+
|
49
|
+
method = Elasticsearch::API::HTTP_GET
|
50
|
+
path = if _index && _type && _id
|
51
|
+
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_explain"
|
52
|
+
else
|
53
|
+
"#{Utils.__listify(_index)}/_explain/#{Utils.__listify(_id)}"
|
54
|
+
end
|
55
|
+
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
56
|
+
|
57
|
+
body = arguments[:body]
|
63
58
|
perform_request(method, path, params, body).body
|
64
59
|
end
|
65
60
|
|
66
61
|
# Register this action with its valid params when the module is loaded.
|
67
62
|
#
|
68
|
-
# @since 6.
|
63
|
+
# @since 6.2.0
|
69
64
|
ParamsRegistry.register(:explain, [
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
65
|
+
:analyze_wildcard,
|
66
|
+
:analyzer,
|
67
|
+
:default_operator,
|
68
|
+
:df,
|
69
|
+
:stored_fields,
|
70
|
+
:lenient,
|
71
|
+
:preference,
|
72
|
+
:q,
|
73
|
+
:routing,
|
74
|
+
:_source,
|
75
|
+
:_source_excludes,
|
76
|
+
:_source_includes
|
77
|
+
].freeze)
|
78
|
+
end
|
83
79
|
end
|
84
|
-
end
|
85
80
|
end
|
@@ -5,40 +5,47 @@
|
|
5
5
|
module Elasticsearch
|
6
6
|
module API
|
7
7
|
module Actions
|
8
|
-
|
9
|
-
# Return the capabilities of fields among multiple indices
|
10
|
-
#
|
11
|
-
# @example
|
12
|
-
# client.field_caps fields: '*'
|
13
|
-
# # => { "fields" => "t"=>{"text"=>{"type"=>"text", "searchable"=>true, "aggregatable"=>false}} ...
|
8
|
+
# Returns the information about the capabilities of fields among multiple indices.
|
14
9
|
#
|
15
10
|
# @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
|
16
11
|
# @option arguments [List] :fields A comma-separated list of field names
|
17
12
|
# @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
18
13
|
# @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)
|
19
|
-
# @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
14
|
+
# @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
15
|
+
# (options: open,closed,none,all)
|
16
|
+
|
17
|
+
# @option arguments [Boolean] :include_unmapped Indicates whether unmapped fields should be included in the response.
|
18
|
+
|
20
19
|
#
|
21
|
-
# @see
|
20
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-field-caps.html
|
22
21
|
#
|
23
|
-
def field_caps(arguments={})
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
def field_caps(arguments = {})
|
23
|
+
arguments = arguments.clone
|
24
|
+
|
25
|
+
_index = arguments.delete(:index)
|
26
|
+
|
27
|
+
method = Elasticsearch::API::HTTP_GET
|
28
|
+
path = if _index
|
29
|
+
"#{Utils.__listify(_index)}/_field_caps"
|
30
|
+
else
|
31
|
+
"_field_caps"
|
32
|
+
end
|
27
33
|
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
28
|
-
body = arguments[:body]
|
29
34
|
|
35
|
+
body = nil
|
30
36
|
perform_request(method, path, params, body).body
|
31
37
|
end
|
32
38
|
|
33
39
|
# Register this action with its valid params when the module is loaded.
|
34
40
|
#
|
35
|
-
# @since 6.
|
41
|
+
# @since 6.2.0
|
36
42
|
ParamsRegistry.register(:field_caps, [
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
43
|
+
:fields,
|
44
|
+
:ignore_unavailable,
|
45
|
+
:allow_no_indices,
|
46
|
+
:expand_wildcards,
|
47
|
+
:include_unmapped
|
48
|
+
].freeze)
|
49
|
+
end
|
42
50
|
end
|
43
|
-
end
|
44
51
|
end
|
@@ -5,20 +5,12 @@
|
|
5
5
|
module Elasticsearch
|
6
6
|
module API
|
7
7
|
module Actions
|
8
|
-
|
9
|
-
# Return a specified document.
|
10
|
-
#
|
11
|
-
# The response contains full document, as stored in Elasticsearch, incl. `_source`, `_version`, etc.
|
12
|
-
#
|
13
|
-
# @example Get a document
|
14
|
-
#
|
15
|
-
# client.get index: 'myindex', type: 'mytype', id: '1'
|
8
|
+
# Returns a document.
|
16
9
|
#
|
17
|
-
# @option arguments [String] :id The document ID
|
18
|
-
# @option arguments [String] :index The name of the index
|
19
|
-
# @option arguments [String] :type The type of the document (use `_all` to fetch the first document matching the ID across all types)
|
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 (use `_all` to fetch the first document matching the ID across all types) *Deprecated*
|
20
13
|
# @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response
|
21
|
-
# @option arguments [String] :parent The ID of the parent document
|
22
14
|
# @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
|
23
15
|
# @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode
|
24
16
|
# @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation
|
@@ -26,28 +18,39 @@ module Elasticsearch
|
|
26
18
|
# @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return
|
27
19
|
# @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field
|
28
20
|
# @option arguments [List] :_source_includes A list of fields to extract and return from the _source field
|
29
|
-
# @option arguments [List] :_source_exclude A list of fields to exclude from the returned _source field
|
30
|
-
# @option arguments [List] :_source_include A list of fields to extract and return from the _source field
|
31
21
|
# @option arguments [Number] :version Explicit version number for concurrency control
|
32
|
-
# @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
|
29
|
+
#
|
33
30
|
#
|
34
|
-
# @see
|
31
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-get.html
|
35
32
|
#
|
36
|
-
def get(arguments={})
|
33
|
+
def get(arguments = {})
|
37
34
|
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
|
38
|
-
raise ArgumentError, "Required argument 'id' missing"
|
39
|
-
arguments[:type] ||= DEFAULT_DOC
|
35
|
+
raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
|
40
36
|
|
41
|
-
|
42
|
-
path = Utils.__pathify Utils.__escape(arguments[:index]),
|
43
|
-
Utils.__escape(arguments[:type]),
|
44
|
-
Utils.__escape(arguments[:id])
|
37
|
+
arguments = arguments.clone
|
45
38
|
|
46
|
-
|
47
|
-
|
39
|
+
_id = arguments.delete(:id)
|
40
|
+
|
41
|
+
_index = arguments.delete(:index)
|
48
42
|
|
49
|
-
|
43
|
+
_type = arguments.delete(:type)
|
50
44
|
|
45
|
+
method = Elasticsearch::API::HTTP_GET
|
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
|
51
|
+
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
52
|
+
|
53
|
+
body = nil
|
51
54
|
if Array(arguments[:ignore]).include?(404)
|
52
55
|
Utils.__rescue_from_not_found { perform_request(method, path, params, body).body }
|
53
56
|
else
|
@@ -57,21 +60,19 @@ module Elasticsearch
|
|
57
60
|
|
58
61
|
# Register this action with its valid params when the module is loaded.
|
59
62
|
#
|
60
|
-
# @since 6.
|
63
|
+
# @since 6.2.0
|
61
64
|
ParamsRegistry.register(:get, [
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
:version_type ].freeze)
|
65
|
+
:stored_fields,
|
66
|
+
:preference,
|
67
|
+
:realtime,
|
68
|
+
:refresh,
|
69
|
+
:routing,
|
70
|
+
:_source,
|
71
|
+
:_source_excludes,
|
72
|
+
:_source_includes,
|
73
|
+
:version,
|
74
|
+
:version_type
|
75
|
+
].freeze)
|
76
|
+
end
|
75
77
|
end
|
76
|
-
end
|
77
78
|
end
|
@@ -5,30 +5,35 @@
|
|
5
5
|
module Elasticsearch
|
6
6
|
module API
|
7
7
|
module Actions
|
8
|
-
|
9
|
-
# Retrieve an indexed script from Elasticsearch
|
8
|
+
# Returns a script.
|
10
9
|
#
|
11
|
-
# @option arguments [String] :id Script ID
|
12
|
-
# @option arguments [
|
10
|
+
# @option arguments [String] :id Script ID
|
11
|
+
# @option arguments [Time] :master_timeout Specify timeout for connection to master
|
12
|
+
|
13
13
|
#
|
14
|
-
# @see https://www.elastic.co/guide/en/elasticsearch/reference/
|
14
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/modules-scripting.html
|
15
15
|
#
|
16
|
-
def get_script(arguments={})
|
17
|
-
raise ArgumentError, "Required argument 'id' missing"
|
16
|
+
def get_script(arguments = {})
|
17
|
+
raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
|
18
|
+
|
19
|
+
arguments = arguments.clone
|
20
|
+
|
21
|
+
_id = arguments.delete(:id)
|
22
|
+
|
18
23
|
method = Elasticsearch::API::HTTP_GET
|
19
|
-
path = "_scripts/#{
|
20
|
-
params =
|
21
|
-
body = nil
|
24
|
+
path = "_scripts/#{Utils.__listify(_id)}"
|
25
|
+
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
22
26
|
|
27
|
+
body = nil
|
23
28
|
perform_request(method, path, params, body).body
|
24
29
|
end
|
25
30
|
|
26
|
-
|
27
31
|
# Register this action with its valid params when the module is loaded.
|
28
32
|
#
|
29
|
-
# @since 6.
|
33
|
+
# @since 6.2.0
|
30
34
|
ParamsRegistry.register(:get_script, [
|
31
|
-
|
35
|
+
:master_timeout
|
36
|
+
].freeze)
|
37
|
+
end
|
32
38
|
end
|
33
|
-
end
|
34
39
|
end
|
@@ -5,19 +5,11 @@
|
|
5
5
|
module Elasticsearch
|
6
6
|
module API
|
7
7
|
module Actions
|
8
|
-
|
9
|
-
# Return a specified document's `_source`.
|
10
|
-
#
|
11
|
-
# The response contains just the original document, as passed to Elasticsearch during indexing.
|
12
|
-
#
|
13
|
-
# @example Get a document `_source`
|
8
|
+
# Returns the source of a document.
|
14
9
|
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
# @option arguments [String] :
|
18
|
-
# @option arguments [String] :index The name of the index (*Required*)
|
19
|
-
# @option arguments [String] :type The type of the document; deprecated and optional starting with 7.0
|
20
|
-
# @option arguments [String] :parent The ID of the parent 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 and optional starting with 7.0 *Deprecated*
|
21
13
|
# @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
|
22
14
|
# @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode
|
23
15
|
# @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation
|
@@ -26,53 +18,55 @@ module Elasticsearch
|
|
26
18
|
# @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field
|
27
19
|
# @option arguments [List] :_source_includes A list of fields to extract and return from the _source field
|
28
20
|
# @option arguments [Number] :version Explicit version number for concurrency control
|
29
|
-
# @option arguments [String] :version_type Specific version type
|
21
|
+
# @option arguments [String] :version_type Specific version type
|
22
|
+
# (options: internal,external,external_gte,force)
|
23
|
+
|
24
|
+
#
|
25
|
+
# *Deprecation notice*:
|
26
|
+
# Specifying types in urls has been deprecated
|
27
|
+
# Deprecated since version 7.0.0
|
30
28
|
#
|
31
|
-
# @see http://elasticsearch.org/guide/reference/api/get/
|
32
29
|
#
|
33
|
-
# @
|
30
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-get.html
|
34
31
|
#
|
35
|
-
def get_source(arguments={})
|
32
|
+
def get_source(arguments = {})
|
36
33
|
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
|
37
|
-
raise ArgumentError, "Required argument 'id' missing"
|
38
|
-
arguments[:type] ||= DEFAULT_DOC
|
34
|
+
raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
|
39
35
|
|
40
|
-
|
36
|
+
arguments = arguments.clone
|
41
37
|
|
42
|
-
|
43
|
-
path = Utils.__pathify Utils.__escape(arguments[:index]),
|
44
|
-
Utils.__escape(arguments[:type]),
|
45
|
-
Utils.__escape(arguments[:id]),
|
46
|
-
'_source'
|
47
|
-
else
|
48
|
-
path = Utils.__pathify Utils.__escape(arguments[:index]),
|
49
|
-
'_source',
|
50
|
-
Utils.__escape(arguments[:id])
|
51
|
-
end
|
38
|
+
_id = arguments.delete(:id)
|
52
39
|
|
40
|
+
_index = arguments.delete(:index)
|
53
41
|
|
54
|
-
|
55
|
-
body = nil
|
42
|
+
_type = arguments.delete(:type)
|
56
43
|
|
57
|
-
|
44
|
+
method = Elasticsearch::API::HTTP_GET
|
45
|
+
path = if _index && _type && _id
|
46
|
+
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_source"
|
47
|
+
else
|
48
|
+
"#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}"
|
49
|
+
end
|
50
|
+
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
58
51
|
|
52
|
+
body = nil
|
59
53
|
perform_request(method, path, params, body).body
|
60
54
|
end
|
61
55
|
|
62
56
|
# Register this action with its valid params when the module is loaded.
|
63
57
|
#
|
64
|
-
# @since 6.
|
58
|
+
# @since 6.2.0
|
65
59
|
ParamsRegistry.register(:get_source, [
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
60
|
+
:preference,
|
61
|
+
:realtime,
|
62
|
+
:refresh,
|
63
|
+
:routing,
|
64
|
+
:_source,
|
65
|
+
:_source_excludes,
|
66
|
+
:_source_includes,
|
67
|
+
:version,
|
68
|
+
:version_type
|
69
|
+
].freeze)
|
70
|
+
end
|
76
71
|
end
|
77
|
-
end
|
78
72
|
end
|