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,43 +5,11 @@
|
|
5
5
|
module Elasticsearch
|
6
6
|
module API
|
7
7
|
module Actions
|
8
|
-
|
9
|
-
# Return information and statistics about terms in the fields of a particular document
|
10
|
-
#
|
11
|
-
# @example Get statistics for an indexed document
|
12
|
-
#
|
13
|
-
# client.indices.create index: 'my_index',
|
14
|
-
# body: {
|
15
|
-
# mappings: {
|
16
|
-
# properties: {
|
17
|
-
# text: {
|
18
|
-
# type: 'string',
|
19
|
-
# term_vector: 'with_positions_offsets_payloads'
|
20
|
-
# }
|
21
|
-
# }
|
22
|
-
# }
|
23
|
-
# }
|
24
|
-
#
|
25
|
-
# client.index index: 'my_index', type: 'my_type', id: '1', body: { text: 'Foo Bar Fox' }
|
26
|
-
#
|
27
|
-
# client.termvectors index: 'my_index', type: 'my_type', id: '1'
|
28
|
-
# # => { ..., "term_vectors" => { "text" => { "field_statistics" => { ... }, "terms" => { "bar" => ... } } }
|
29
|
-
#
|
30
|
-
#
|
31
|
-
# @example Get statistics for an arbitrary document
|
8
|
+
# Returns information and statistics about terms in the fields of a particular document.
|
32
9
|
#
|
33
|
-
#
|
34
|
-
# body: {
|
35
|
-
# doc: {
|
36
|
-
# text: 'Foo Bar Fox'
|
37
|
-
# }
|
38
|
-
# }
|
39
|
-
# # => { ..., "term_vectors" => { "text" => { "field_statistics" => { ... }, "terms" => { "bar" => ... } } }
|
40
|
-
#
|
41
|
-
# @option arguments [String] :index The index in which the document resides. (*Required*)
|
42
|
-
# @option arguments [String] :type The type of the document.
|
10
|
+
# @option arguments [String] :index The index in which the document resides. (*Required*)
|
43
11
|
# @option arguments [String] :id The id of the document, when not specified a doc param should be supplied.
|
44
|
-
# @option arguments [
|
12
|
+
# @option arguments [String] :type The type of the document.
|
45
13
|
# @option arguments [Boolean] :term_statistics Specifies if total term frequency and document frequency should be returned.
|
46
14
|
# @option arguments [Boolean] :field_statistics Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned.
|
47
15
|
# @option arguments [List] :fields A comma-separated list of fields to return.
|
@@ -50,57 +18,71 @@ module Elasticsearch
|
|
50
18
|
# @option arguments [Boolean] :payloads Specifies if term payloads should be returned.
|
51
19
|
# @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random).
|
52
20
|
# @option arguments [String] :routing Specific routing value.
|
53
|
-
# @option arguments [String] :parent Parent id of documents.
|
54
21
|
# @option arguments [Boolean] :realtime Specifies if request is real-time as opposed to near-real-time (default: true).
|
55
22
|
# @option arguments [Number] :version Explicit version number for concurrency control
|
56
|
-
# @option arguments [String] :version_type Specific version type
|
23
|
+
# @option arguments [String] :version_type Specific version type
|
24
|
+
# (options: internal,external,external_gte,force)
|
25
|
+
|
26
|
+
# @option arguments [Hash] :body Define parameters and or supply a document to get termvectors for. See documentation.
|
57
27
|
#
|
58
|
-
#
|
28
|
+
# *Deprecation notice*:
|
29
|
+
# Specifying types in urls has been deprecated
|
30
|
+
# Deprecated since version 7.0.0
|
59
31
|
#
|
60
|
-
|
32
|
+
#
|
33
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-termvectors.html
|
34
|
+
#
|
35
|
+
def termvectors(arguments = {})
|
61
36
|
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
|
62
|
-
method = HTTP_GET
|
63
|
-
endpoint = arguments.delete(:endpoint) || '_termvectors'
|
64
37
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
38
|
+
arguments = arguments.clone
|
39
|
+
|
40
|
+
_index = arguments.delete(:index)
|
41
|
+
|
42
|
+
_id = arguments.delete(:id)
|
43
|
+
|
44
|
+
_type = arguments.delete(:type)
|
45
|
+
|
46
|
+
method = Elasticsearch::API::HTTP_GET
|
47
|
+
|
48
|
+
endpoint = arguments.delete(:endpoint) || '_termvectors'
|
49
|
+
path = if _index && _type && _id
|
50
|
+
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/#{endpoint}"
|
51
|
+
elsif _index && _type
|
52
|
+
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{endpoint}"
|
53
|
+
elsif _index && _id
|
54
|
+
"#{Utils.__listify(_index)}/#{endpoint}/#{Utils.__listify(_id)}"
|
55
|
+
else
|
56
|
+
"#{Utils.__listify(_index)}/#{endpoint}"
|
57
|
+
end
|
75
58
|
|
76
59
|
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
77
|
-
body = arguments[:body]
|
78
60
|
|
61
|
+
body = arguments[:body]
|
79
62
|
perform_request(method, path, params, body).body
|
80
63
|
end
|
81
64
|
|
82
|
-
#
|
65
|
+
# Deprecated: Use the plural version, {#termvectors}
|
83
66
|
#
|
84
|
-
def termvector(arguments={})
|
85
|
-
termvectors(arguments.merge :
|
67
|
+
def termvector(arguments = {})
|
68
|
+
termvectors(arguments.merge endpoint: '_termvector')
|
86
69
|
end
|
87
|
-
|
88
70
|
# Register this action with its valid params when the module is loaded.
|
89
71
|
#
|
90
|
-
# @since 6.
|
72
|
+
# @since 6.2.0
|
91
73
|
ParamsRegistry.register(:termvectors, [
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
74
|
+
:term_statistics,
|
75
|
+
:field_statistics,
|
76
|
+
:fields,
|
77
|
+
:offsets,
|
78
|
+
:positions,
|
79
|
+
:payloads,
|
80
|
+
:preference,
|
81
|
+
:routing,
|
82
|
+
:realtime,
|
83
|
+
:version,
|
84
|
+
:version_type
|
85
|
+
].freeze)
|
86
|
+
end
|
104
87
|
end
|
105
|
-
end
|
106
88
|
end
|
@@ -5,92 +5,56 @@
|
|
5
5
|
module Elasticsearch
|
6
6
|
module API
|
7
7
|
module Actions
|
8
|
+
# Updates a document with a script or partial document.
|
9
|
+
#
|
10
|
+
# @option arguments [String] :id Document ID
|
11
|
+
# @option arguments [String] :index The name of the index
|
12
|
+
# @option arguments [String] :type The type of the document *Deprecated*
|
13
|
+
# @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the update 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)
|
14
|
+
# @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return
|
15
|
+
# @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field
|
16
|
+
# @option arguments [List] :_source_includes A list of fields to extract and return from the _source field
|
17
|
+
# @option arguments [String] :lang The script language (default: painless)
|
18
|
+
# @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.
|
19
|
+
# (options: true,false,wait_for)
|
8
20
|
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# Send either a partial document (`doc` ) which will be deeply merged into an existing document,
|
12
|
-
# or a `script`, which will update the document content, in the `:body` argument.
|
13
|
-
#
|
14
|
-
# The partial update operation allows you to limit the amount of data you send over the wire and
|
15
|
-
# reduces the chance of failed updates due to conflict.
|
16
|
-
#
|
17
|
-
# Specify the `:version` and `:retry_on_conflict` arguments to balance convenience and consistency.
|
18
|
-
#
|
19
|
-
# @example Update document _title_ using partial `doc`-ument
|
20
|
-
#
|
21
|
-
# client.update index: 'myindex', type: 'mytype', id: '1',
|
22
|
-
# body: { doc: { title: 'Updated' } }
|
23
|
-
#
|
24
|
-
# @example Add a tag to document `tags` property using a `script`
|
25
|
-
#
|
26
|
-
# client.update index: 'myindex', type: 'mytype', id: '1',
|
27
|
-
# body: { script: { source: 'ctx._source.tags.add(params.tag)', params: { tag: 'x' } } }
|
28
|
-
#
|
29
|
-
# @example Increment a document counter by 1 _or_ initialize it, when the document does not exist
|
30
|
-
#
|
31
|
-
# client.update index: 'myindex', type: 'mytype', id: '666',
|
32
|
-
# body: { script: 'ctx._source.counter += 1', upsert: { counter: 1 } }
|
33
|
-
#
|
34
|
-
# @example Delete a document if it's tagged "to-delete"
|
35
|
-
#
|
36
|
-
# client.update index: 'myindex', type: 'mytype', id: '1',
|
37
|
-
# body: { script: 'ctx._source.tags.contains(params.tag) ? ctx.op = "delete" : ctx.op = "none"',
|
38
|
-
# params: { tag: 'to-delete' } }
|
39
|
-
#
|
40
|
-
# @option arguments [String] :id Document ID (*Required*)
|
41
|
-
# @option arguments [Number,List] :ignore The list of HTTP errors to ignore; only `404` supported at the moment
|
42
|
-
# @option arguments [String] :index The name of the index (*Required*)
|
43
|
-
# @option arguments [String] :type The type of the document (*Required*)
|
44
|
-
# @option arguments [Hash] :body The request definition using either `script` or partial `doc` (*Required*)
|
45
|
-
# @option arguments [String] :consistency Explicit write consistency setting for the operation
|
46
|
-
# (options: one, quorum, all)
|
47
|
-
# @option arguments [List] :fields A comma-separated list of fields to return in the response
|
48
|
-
# @option arguments [Boolean] :include_type_name Whether a type should be expected in the body of the mappings.
|
49
|
-
# @option arguments [String] :lang The script language (default: mvel)
|
50
|
-
# @option arguments [String] :parent ID of the parent document
|
51
|
-
# @option arguments [String] :percolate Perform percolation during the operation;
|
52
|
-
# use specific registered query name, attribute, or wildcard
|
53
|
-
# @option arguments [Boolean] :refresh Refresh the index after performing the operation
|
54
|
-
# @option arguments [String] :replication Specific replication type (options: sync, async)
|
55
|
-
# @option arguments [Number] :retry_on_conflict Specify how many times should the operation be retried
|
56
|
-
# when a conflict occurs (default: 0)
|
21
|
+
# @option arguments [Number] :retry_on_conflict Specify how many times should the operation be retried when a conflict occurs (default: 0)
|
57
22
|
# @option arguments [String] :routing Specific routing value
|
58
|
-
# @option arguments [String] :script The URL-encoded script definition (instead of using request body)
|
59
|
-
# @option arguments [String] :_source Specify whether the _source field should be returned,
|
60
|
-
# or a list of fields to return
|
61
|
-
# @option arguments [String] :_source_exclude A list of fields to exclude from the returned _source field
|
62
|
-
# @option arguments [String] :_source_include A list of fields to extract and return from the _source field
|
63
23
|
# @option arguments [Time] :timeout Explicit operation timeout
|
64
|
-
# @option arguments [
|
65
|
-
# @option arguments [
|
66
|
-
|
67
|
-
# @option arguments [
|
24
|
+
# @option arguments [Number] :if_seq_no only perform the update operation if the last operation that has changed the document has the specified sequence number
|
25
|
+
# @option arguments [Number] :if_primary_term only perform the update operation if the last operation that has changed the document has the specified primary term
|
26
|
+
|
27
|
+
# @option arguments [Hash] :body The request definition requires either `script` or partial `doc` (*Required*)
|
28
|
+
#
|
29
|
+
# *Deprecation notice*:
|
30
|
+
# Specifying types in urls has been deprecated
|
31
|
+
# Deprecated since version 7.0.0
|
68
32
|
#
|
69
|
-
# @since 0.20
|
70
33
|
#
|
71
|
-
# @see
|
34
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-update.html
|
72
35
|
#
|
73
|
-
def update(arguments={})
|
36
|
+
def update(arguments = {})
|
37
|
+
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
|
74
38
|
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
|
75
|
-
raise ArgumentError, "Required argument 'id' missing"
|
76
|
-
arguments[:type] ||= DEFAULT_DOC
|
77
|
-
method = HTTP_POST
|
39
|
+
raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
|
78
40
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
Utils.__escape(arguments[:id]),
|
83
|
-
'_update'
|
84
|
-
else
|
85
|
-
path = Utils.__pathify Utils.__escape(arguments[:index]),
|
86
|
-
'_update',
|
87
|
-
Utils.__escape(arguments[:id])
|
88
|
-
end
|
41
|
+
arguments = arguments.clone
|
42
|
+
|
43
|
+
_id = arguments.delete(:id)
|
89
44
|
|
45
|
+
_index = arguments.delete(:index)
|
46
|
+
|
47
|
+
_type = arguments.delete(:type)
|
48
|
+
|
49
|
+
method = Elasticsearch::API::HTTP_POST
|
50
|
+
path = if _index && _type && _id
|
51
|
+
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_update"
|
52
|
+
else
|
53
|
+
"#{Utils.__listify(_index)}/_update/#{Utils.__listify(_id)}"
|
54
|
+
end
|
90
55
|
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
91
|
-
body = arguments[:body]
|
92
|
-
params[:fields] = Utils.__listify(params[:fields]) if params[:fields]
|
93
56
|
|
57
|
+
body = arguments[:body]
|
94
58
|
if Array(arguments[:ignore]).include?(404)
|
95
59
|
Utils.__rescue_from_not_found { perform_request(method, path, params, body).body }
|
96
60
|
else
|
@@ -100,29 +64,20 @@ module Elasticsearch
|
|
100
64
|
|
101
65
|
# Register this action with its valid params when the module is loaded.
|
102
66
|
#
|
103
|
-
# @since 6.
|
67
|
+
# @since 6.2.0
|
104
68
|
ParamsRegistry.register(:update, [
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
:_source_exclude,
|
119
|
-
:timeout,
|
120
|
-
:timestamp,
|
121
|
-
:ttl,
|
122
|
-
:version,
|
123
|
-
:version_type,
|
124
|
-
:if_seq_no,
|
125
|
-
:if_primary_term ].freeze)
|
69
|
+
:wait_for_active_shards,
|
70
|
+
:_source,
|
71
|
+
:_source_excludes,
|
72
|
+
:_source_includes,
|
73
|
+
:lang,
|
74
|
+
:refresh,
|
75
|
+
:retry_on_conflict,
|
76
|
+
:routing,
|
77
|
+
:timeout,
|
78
|
+
:if_seq_no,
|
79
|
+
:if_primary_term
|
80
|
+
].freeze)
|
81
|
+
end
|
126
82
|
end
|
127
|
-
end
|
128
83
|
end
|
@@ -5,42 +5,38 @@
|
|
5
5
|
module Elasticsearch
|
6
6
|
module API
|
7
7
|
module Actions
|
8
|
-
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# @example Update all documents in the index, eg. to pick up new mappings
|
12
|
-
#
|
13
|
-
# client.update_by_query index: 'articles'
|
14
|
-
#
|
15
|
-
# @example Update a property of documents matching a query in the index
|
16
|
-
#
|
17
|
-
# client.update_by_query index: 'article',
|
18
|
-
# body: {
|
19
|
-
# script: { inline: 'ctx._source.views += 1' },
|
20
|
-
# query: { match: { title: 'foo' } }
|
21
|
-
# }
|
8
|
+
# Performs an update on every document in the index without changing the source,
|
9
|
+
# for example to pick up a mapping change.
|
22
10
|
#
|
23
|
-
# @option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
|
11
|
+
# @option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices (*Required*)
|
24
12
|
# @option arguments [List] :type A comma-separated list of document types to search; leave empty to perform the operation on all types
|
25
|
-
# @option arguments [Hash] :body The search definition using the Query DSL
|
26
13
|
# @option arguments [String] :analyzer The analyzer to use for the query string
|
27
14
|
# @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false)
|
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 field to use as default where no field prefix is given in the query string
|
30
19
|
# @option arguments [Number] :from Starting offset (default: 0)
|
31
20
|
# @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
32
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)
|
33
|
-
# @option arguments [String] :conflicts What to do when the update by query hits version conflicts?
|
34
|
-
#
|
22
|
+
# @option arguments [String] :conflicts What to do when the update by query hits version conflicts?
|
23
|
+
# (options: abort,proceed)
|
24
|
+
|
25
|
+
# @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
26
|
+
# (options: open,closed,none,all)
|
27
|
+
|
35
28
|
# @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
|
36
29
|
# @option arguments [String] :pipeline Ingest pipeline to set on index requests made by this action. (default: none)
|
37
30
|
# @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
|
38
31
|
# @option arguments [String] :q Query in the Lucene query string syntax
|
39
32
|
# @option arguments [List] :routing A comma-separated list of specific routing values
|
40
33
|
# @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search
|
41
|
-
# @option arguments [String] :search_type Search operation type
|
34
|
+
# @option arguments [String] :search_type Search operation type
|
35
|
+
# (options: query_then_fetch,dfs_query_then_fetch)
|
36
|
+
|
42
37
|
# @option arguments [Time] :search_timeout Explicit timeout for each search request. Defaults to no timeout.
|
43
|
-
# @option arguments [Number] :size
|
38
|
+
# @option arguments [Number] :size Deprecated, please use `max_docs` instead
|
39
|
+
# @option arguments [Number] :max_docs Maximum number of documents to process (default: all documents)
|
44
40
|
# @option arguments [List] :sort A comma-separated list of <field>:<direction> pairs
|
45
41
|
# @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return
|
46
42
|
# @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field
|
@@ -50,69 +46,84 @@ module Elasticsearch
|
|
50
46
|
# @option arguments [Boolean] :version Specify whether to return document version as part of a hit
|
51
47
|
# @option arguments [Boolean] :version_type Should the document increment the version number (internal) on hit or not (reindex)
|
52
48
|
# @option arguments [Boolean] :request_cache Specify if request cache should be used for this request or not, defaults to index level setting
|
53
|
-
# @option arguments [Boolean] :refresh Should the
|
49
|
+
# @option arguments [Boolean] :refresh Should the affected indexes be refreshed?
|
54
50
|
# @option arguments [Time] :timeout Time each individual bulk request should wait for shards that are unavailable.
|
55
51
|
# @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the update by query 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)
|
56
52
|
# @option arguments [Number] :scroll_size Size on the scroll request powering the update by query
|
57
53
|
# @option arguments [Boolean] :wait_for_completion Should the request should block until the update by query operation is complete.
|
58
54
|
# @option arguments [Number] :requests_per_second The throttle to set on this request in sub-requests per second. -1 means no throttle.
|
59
55
|
# @option arguments [Number] :slices The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks.
|
56
|
+
|
57
|
+
# @option arguments [Hash] :body The search definition using the Query DSL
|
58
|
+
#
|
59
|
+
# *Deprecation notice*:
|
60
|
+
# Specifying types in urls has been deprecated
|
61
|
+
# Deprecated since version 7.0.0
|
60
62
|
#
|
61
|
-
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html
|
62
63
|
#
|
63
|
-
|
64
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-update-by-query.html
|
65
|
+
#
|
66
|
+
def update_by_query(arguments = {})
|
64
67
|
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
|
65
|
-
method = HTTP_POST
|
66
68
|
|
67
|
-
|
68
|
-
Utils.__listify(arguments[:type]),
|
69
|
-
'/_update_by_query'
|
69
|
+
arguments = arguments.clone
|
70
70
|
|
71
|
-
|
71
|
+
_index = arguments.delete(:index)
|
72
72
|
|
73
|
-
|
73
|
+
_type = arguments.delete(:type)
|
74
74
|
|
75
|
+
method = Elasticsearch::API::HTTP_POST
|
76
|
+
path = if _index && _type
|
77
|
+
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_update_by_query"
|
78
|
+
else
|
79
|
+
"#{Utils.__listify(_index)}/_update_by_query"
|
80
|
+
end
|
81
|
+
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
82
|
+
|
83
|
+
body = arguments[:body]
|
75
84
|
perform_request(method, path, params, body).body
|
76
85
|
end
|
77
86
|
|
78
87
|
# Register this action with its valid params when the module is loaded.
|
79
88
|
#
|
80
|
-
# @since 6.
|
89
|
+
# @since 6.2.0
|
81
90
|
ParamsRegistry.register(:update_by_query, [
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
91
|
+
:analyzer,
|
92
|
+
:analyze_wildcard,
|
93
|
+
:default_operator,
|
94
|
+
:df,
|
95
|
+
:from,
|
96
|
+
:ignore_unavailable,
|
97
|
+
:allow_no_indices,
|
98
|
+
:conflicts,
|
99
|
+
:expand_wildcards,
|
100
|
+
:lenient,
|
101
|
+
:pipeline,
|
102
|
+
:preference,
|
103
|
+
:q,
|
104
|
+
:routing,
|
105
|
+
:scroll,
|
106
|
+
:search_type,
|
107
|
+
:search_timeout,
|
108
|
+
:size,
|
109
|
+
:max_docs,
|
110
|
+
:sort,
|
111
|
+
:_source,
|
112
|
+
:_source_excludes,
|
113
|
+
:_source_includes,
|
114
|
+
:terminate_after,
|
115
|
+
:stats,
|
116
|
+
:version,
|
117
|
+
:version_type,
|
118
|
+
:request_cache,
|
119
|
+
:refresh,
|
120
|
+
:timeout,
|
121
|
+
:wait_for_active_shards,
|
122
|
+
:scroll_size,
|
123
|
+
:wait_for_completion,
|
124
|
+
:requests_per_second,
|
125
|
+
:slices
|
126
|
+
].freeze)
|
127
|
+
end
|
116
128
|
end
|
117
|
-
end
|
118
129
|
end
|