elasticsearch-api 8.0.0.pre1 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/api-spec-testing/test_file/action.rb +11 -0
- data/api-spec-testing/wipe_cluster.rb +2 -1
- data/elasticsearch-api.gemspec +8 -1
- data/lib/elasticsearch/api/actions/bulk.rb +1 -6
- data/lib/elasticsearch/api/actions/count.rb +6 -1
- data/lib/elasticsearch/api/actions/create.rb +0 -6
- data/lib/elasticsearch/api/actions/delete.rb +1 -13
- data/lib/elasticsearch/api/actions/delete_by_query.rb +0 -3
- data/lib/elasticsearch/api/actions/exists_source.rb +1 -13
- data/lib/elasticsearch/api/actions/indices/stats.rb +0 -1
- data/lib/elasticsearch/api/actions/indices/validate_query.rb +1 -11
- data/lib/elasticsearch/api/actions/machine_learning/forecast.rb +2 -1
- data/lib/elasticsearch/api/actions/machine_learning/get_model_snapshot_upgrade_stats.rb +56 -0
- data/lib/elasticsearch/api/actions/machine_learning/open_job.rb +2 -1
- data/lib/elasticsearch/api/actions/rollup/rollup_search.rb +1 -13
- data/lib/elasticsearch/api/actions/transform/delete_transform.rb +1 -0
- data/lib/elasticsearch/api/actions/transform/preview_transform.rb +2 -1
- data/lib/elasticsearch/api/actions/transform/put_transform.rb +1 -0
- data/lib/elasticsearch/api/actions/transform/update_transform.rb +1 -0
- data/lib/elasticsearch/api/actions/transform/upgrade_transforms.rb +1 -0
- data/lib/elasticsearch/api/actions/update.rb +1 -13
- data/lib/elasticsearch/api/actions/update_by_query.rb +0 -3
- data/lib/elasticsearch/api/utils.rb +2 -3
- data/lib/elasticsearch/api/version.rb +1 -1
- data/spec/elasticsearch/api/actions/bulk_spec.rb +10 -29
- data/spec/elasticsearch/api/actions/count_spec.rb +2 -5
- data/spec/elasticsearch/api/actions/delete_document_spec.rb +9 -9
- data/spec/elasticsearch/api/actions/indices/validate_query_spec.rb +0 -10
- data/spec/elasticsearch/api/actions/machine_learning/get_model_snapshot_upgrade_stats_spec.rb +56 -0
- data/spec/elasticsearch/api/actions/update_document_spec.rb +10 -10
- data/spec/elasticsearch/api/utils_spec.rb +9 -21
- data/spec/skipped_tests_free.yml +8 -0
- data/spec/spec_helper.rb +1 -0
- data/utils/thor/generate_source.rb +16 -11
- metadata +25 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 388aa9ff6dfb05fb34b5e43b2acb1d8ce87ac5550aee779c09aa1608418e77dd
|
4
|
+
data.tar.gz: 1303c8b91066b97bdb69bd31d984babe97db45643e1c197e58dfc3165ea87103
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f0feb4d867eb7df2cd4d2804f92a814c07443d6033d48d396d6bc77bb2386e7e4b13cc12f31c50d0244e039f1d07c00ffc8bf9597f7a1bee966c3646749c742
|
7
|
+
data.tar.gz: cabae881b3f1035137168e6323d992e641eef1a9c1c52ffa9c6772ca69e0b196b0aacd5bad8ece083443a36dbbeec7767c98f27867845913bb17001df083f711
|
@@ -67,6 +67,17 @@ module Elasticsearch
|
|
67
67
|
|
68
68
|
_method = chain[-1]
|
69
69
|
case _method
|
70
|
+
when 'bulk'
|
71
|
+
arguments = prepare_arguments(args, test)
|
72
|
+
arguments[:body].map! do |item|
|
73
|
+
if item.is_a?(Hash)
|
74
|
+
item
|
75
|
+
elsif item.is_a?(String)
|
76
|
+
symbolize_keys(JSON.parse(item))
|
77
|
+
end
|
78
|
+
end if arguments[:body].is_a? Array
|
79
|
+
@response = client.send(_method, arguments)
|
80
|
+
client
|
70
81
|
when 'headers'
|
71
82
|
headers = prepare_arguments(args, test)
|
72
83
|
# TODO: Remove Authorization headers while x_pack_rest_user is fixed
|
@@ -25,7 +25,8 @@ module Elasticsearch
|
|
25
25
|
'ilm-history-ilm-policy', 'slm-history-ilm-policy', 'watch-history-ilm-policy',
|
26
26
|
'ml-size-based-ilm-policy', 'logs', 'metrics', 'synthetics', '7-days-default',
|
27
27
|
'30-days-default', '90-days-default', '180-days-default', '365-days-default',
|
28
|
-
'.fleet-actions-results-ilm-policy', '.deprecation-indexing-ilm-policy'
|
28
|
+
'.fleet-actions-results-ilm-policy', '.deprecation-indexing-ilm-policy',
|
29
|
+
'watch-history-ilm-policy-16', '.monitoring-8-ilm-policy'
|
29
30
|
].freeze
|
30
31
|
|
31
32
|
PLATINUM_TEMPLATES = [
|
data/elasticsearch-api.gemspec
CHANGED
@@ -60,10 +60,17 @@ Gem::Specification.new do |s|
|
|
60
60
|
# Gems for testing integrations
|
61
61
|
s.add_development_dependency 'jsonify'
|
62
62
|
s.add_development_dependency 'hashie'
|
63
|
+
# Temporary support for Ruby 2.6, since it's EOL March 2022:
|
64
|
+
if RUBY_VERSION < '2.7.0'
|
65
|
+
s.add_development_dependency 'jbuilder', '< 7.0.0'
|
66
|
+
else
|
67
|
+
s.add_development_dependency 'activesupport'
|
68
|
+
s.add_development_dependency 'jbuilder'
|
69
|
+
end
|
63
70
|
|
64
71
|
s.add_development_dependency 'cane'
|
65
72
|
s.add_development_dependency 'escape_utils' unless defined? JRUBY_VERSION
|
66
|
-
|
73
|
+
|
67
74
|
s.add_development_dependency 'require-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
|
68
75
|
s.add_development_dependency 'ruby-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
|
69
76
|
s.add_development_dependency 'simplecov'
|
@@ -21,7 +21,6 @@ module Elasticsearch
|
|
21
21
|
# Allows to perform multiple index/update/delete operations in a single request.
|
22
22
|
#
|
23
23
|
# @option arguments [String] :index Default index for items which don't provide one
|
24
|
-
# @option arguments [String] :type Default document type for items which don't provide one
|
25
24
|
# @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the bulk 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)
|
26
25
|
# @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. (options: true, false, wait_for)
|
27
26
|
# @option arguments [String] :routing Specific routing value
|
@@ -48,12 +47,8 @@ module Elasticsearch
|
|
48
47
|
|
49
48
|
_index = arguments.delete(:index)
|
50
49
|
|
51
|
-
_type = arguments.delete(:type)
|
52
|
-
|
53
50
|
method = Elasticsearch::API::HTTP_POST
|
54
|
-
path = if _index
|
55
|
-
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_bulk"
|
56
|
-
elsif _index
|
51
|
+
path = if _index
|
57
52
|
"#{Utils.__listify(_index)}/_bulk"
|
58
53
|
else
|
59
54
|
"_bulk"
|
@@ -49,7 +49,12 @@ module Elasticsearch
|
|
49
49
|
|
50
50
|
_index = arguments.delete(:index)
|
51
51
|
|
52
|
-
method =
|
52
|
+
method = if body
|
53
|
+
Elasticsearch::API::HTTP_POST
|
54
|
+
else
|
55
|
+
Elasticsearch::API::HTTP_GET
|
56
|
+
end
|
57
|
+
|
53
58
|
path = if _index
|
54
59
|
"#{Utils.__listify(_index)}/_count"
|
55
60
|
else
|
@@ -24,7 +24,6 @@ module Elasticsearch
|
|
24
24
|
#
|
25
25
|
# @option arguments [String] :id Document ID
|
26
26
|
# @option arguments [String] :index The name of the index
|
27
|
-
# @option arguments [String] :type The type of the document *Deprecated*
|
28
27
|
# @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)
|
29
28
|
# @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. (options: true, false, wait_for)
|
30
29
|
# @option arguments [String] :routing Specific routing value
|
@@ -35,11 +34,6 @@ module Elasticsearch
|
|
35
34
|
# @option arguments [Hash] :headers Custom HTTP headers
|
36
35
|
# @option arguments [Hash] :body The document (*Required*)
|
37
36
|
#
|
38
|
-
# *Deprecation notice*:
|
39
|
-
# Specifying types in urls has been deprecated
|
40
|
-
# Deprecated since version 7.0.0
|
41
|
-
#
|
42
|
-
#
|
43
37
|
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html
|
44
38
|
#
|
45
39
|
def create(arguments = {})
|
@@ -22,7 +22,6 @@ module Elasticsearch
|
|
22
22
|
#
|
23
23
|
# @option arguments [String] :id The document ID
|
24
24
|
# @option arguments [String] :index The name of the index
|
25
|
-
# @option arguments [String] :type The type of the document *Deprecated*
|
26
25
|
# @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)
|
27
26
|
# @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. (options: true, false, wait_for)
|
28
27
|
# @option arguments [String] :routing Specific routing value
|
@@ -33,11 +32,6 @@ module Elasticsearch
|
|
33
32
|
# @option arguments [String] :version_type Specific version type (options: internal, external, external_gte)
|
34
33
|
# @option arguments [Hash] :headers Custom HTTP headers
|
35
34
|
#
|
36
|
-
# *Deprecation notice*:
|
37
|
-
# Specifying types in urls has been deprecated
|
38
|
-
# Deprecated since version 7.0.0
|
39
|
-
#
|
40
|
-
#
|
41
35
|
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html
|
42
36
|
#
|
43
37
|
def delete(arguments = {})
|
@@ -54,14 +48,8 @@ module Elasticsearch
|
|
54
48
|
|
55
49
|
_index = arguments.delete(:index)
|
56
50
|
|
57
|
-
_type = arguments.delete(:type)
|
58
|
-
|
59
51
|
method = Elasticsearch::API::HTTP_DELETE
|
60
|
-
path =
|
61
|
-
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}"
|
62
|
-
else
|
63
|
-
"#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
|
64
|
-
end
|
52
|
+
path = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
|
65
53
|
params = Utils.process_params(arguments)
|
66
54
|
|
67
55
|
if Array(arguments[:ignore]).include?(404)
|
@@ -39,9 +39,6 @@ module Elasticsearch
|
|
39
39
|
# @option arguments [Time] :search_timeout Explicit timeout for each search request. Defaults to no timeout.
|
40
40
|
# @option arguments [Number] :max_docs Maximum number of documents to process (default: all documents)
|
41
41
|
# @option arguments [List] :sort A comma-separated list of <field>:<direction> pairs
|
42
|
-
# @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return
|
43
|
-
# @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field
|
44
|
-
# @option arguments [List] :_source_includes A list of fields to extract and return from the _source field
|
45
42
|
# @option arguments [Number] :terminate_after The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
|
46
43
|
# @option arguments [List] :stats Specific 'tag' of the request for logging and statistical purposes
|
47
44
|
# @option arguments [Boolean] :version Specify whether to return document version as part of a hit
|
@@ -22,7 +22,6 @@ module Elasticsearch
|
|
22
22
|
#
|
23
23
|
# @option arguments [String] :id The document ID
|
24
24
|
# @option arguments [String] :index The name of the index
|
25
|
-
# @option arguments [String] :type The type of the document; deprecated and optional starting with 7.0 *Deprecated*
|
26
25
|
# @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
|
27
26
|
# @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode
|
28
27
|
# @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation
|
@@ -34,11 +33,6 @@ module Elasticsearch
|
|
34
33
|
# @option arguments [String] :version_type Specific version type (options: internal, external, external_gte)
|
35
34
|
# @option arguments [Hash] :headers Custom HTTP headers
|
36
35
|
#
|
37
|
-
# *Deprecation notice*:
|
38
|
-
# Specifying types in urls has been deprecated
|
39
|
-
# Deprecated since version 7.0.0
|
40
|
-
#
|
41
|
-
#
|
42
36
|
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html
|
43
37
|
#
|
44
38
|
def exists_source(arguments = {})
|
@@ -55,14 +49,8 @@ module Elasticsearch
|
|
55
49
|
|
56
50
|
_index = arguments.delete(:index)
|
57
51
|
|
58
|
-
_type = arguments.delete(:type)
|
59
|
-
|
60
52
|
method = Elasticsearch::API::HTTP_HEAD
|
61
|
-
path =
|
62
|
-
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_source"
|
63
|
-
else
|
64
|
-
"#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}"
|
65
|
-
end
|
53
|
+
path = "#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}"
|
66
54
|
params = Utils.process_params(arguments)
|
67
55
|
|
68
56
|
Elasticsearch::API::Response.new(
|
@@ -28,7 +28,6 @@ module Elasticsearch
|
|
28
28
|
# @option arguments [List] :fields A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards)
|
29
29
|
# @option arguments [List] :groups A comma-separated list of search groups for `search` index metric
|
30
30
|
# @option arguments [String] :level Return stats aggregated at cluster, index or shard level (options: cluster, indices, shards)
|
31
|
-
# @option arguments [List] :types A comma-separated list of document types for the `indexing` index metric
|
32
31
|
# @option arguments [Boolean] :include_segment_file_sizes Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested)
|
33
32
|
# @option arguments [Boolean] :include_unloaded_segments If set to true segment stats will include stats for segments that are not currently loaded into memory
|
34
33
|
# @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
|
@@ -22,7 +22,6 @@ module Elasticsearch
|
|
22
22
|
# Allows a user to validate a potentially expensive query without executing it.
|
23
23
|
#
|
24
24
|
# @option arguments [List] :index A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices
|
25
|
-
# @option arguments [List] :type A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types *Deprecated*
|
26
25
|
# @option arguments [Boolean] :explain Return detailed information about the error
|
27
26
|
# @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
28
27
|
# @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)
|
@@ -38,11 +37,6 @@ module Elasticsearch
|
|
38
37
|
# @option arguments [Hash] :headers Custom HTTP headers
|
39
38
|
# @option arguments [Hash] :body The query definition specified with the Query DSL
|
40
39
|
#
|
41
|
-
# *Deprecation notice*:
|
42
|
-
# Specifying types in urls has been deprecated
|
43
|
-
# Deprecated since version 7.0.0
|
44
|
-
#
|
45
|
-
#
|
46
40
|
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-validate.html
|
47
41
|
#
|
48
42
|
def validate_query(arguments = {})
|
@@ -54,17 +48,13 @@ module Elasticsearch
|
|
54
48
|
|
55
49
|
_index = arguments.delete(:index)
|
56
50
|
|
57
|
-
_type = arguments.delete(:type)
|
58
|
-
|
59
51
|
method = if body
|
60
52
|
Elasticsearch::API::HTTP_POST
|
61
53
|
else
|
62
54
|
Elasticsearch::API::HTTP_GET
|
63
55
|
end
|
64
56
|
|
65
|
-
path = if _index
|
66
|
-
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_validate/query"
|
67
|
-
elsif _index
|
57
|
+
path = if _index
|
68
58
|
"#{Utils.__listify(_index)}/_validate/query"
|
69
59
|
else
|
70
60
|
"_validate/query"
|
@@ -26,6 +26,7 @@ module Elasticsearch
|
|
26
26
|
# @option arguments [Time] :expires_in The time interval after which the forecast expires. Expired forecasts will be deleted at the first opportunity.
|
27
27
|
# @option arguments [String] :max_model_memory The max memory able to be used by the forecast. Default is 20mb.
|
28
28
|
# @option arguments [Hash] :headers Custom HTTP headers
|
29
|
+
# @option arguments [Hash] :body Query parameters can be specified in the body
|
29
30
|
#
|
30
31
|
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-forecast.html
|
31
32
|
#
|
@@ -34,7 +35,7 @@ module Elasticsearch
|
|
34
35
|
|
35
36
|
headers = arguments.delete(:headers) || {}
|
36
37
|
|
37
|
-
body =
|
38
|
+
body = arguments.delete(:body)
|
38
39
|
|
39
40
|
arguments = arguments.clone
|
40
41
|
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
18
|
+
module Elasticsearch
|
19
|
+
module API
|
20
|
+
module MachineLearning
|
21
|
+
module Actions
|
22
|
+
# Gets stats for anomaly detection job model snapshot upgrades that are in progress.
|
23
|
+
#
|
24
|
+
# @option arguments [String] :job_id The ID of the job. May be a wildcard, comma separated list or `_all`.
|
25
|
+
# @option arguments [String] :snapshot_id The ID of the snapshot. May be a wildcard, comma separated list or `_all`.
|
26
|
+
# @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no jobs or no snapshots. (This includes the `_all` string.)
|
27
|
+
# @option arguments [Hash] :headers Custom HTTP headers
|
28
|
+
#
|
29
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-model-snapshot-upgrade-stats.html
|
30
|
+
#
|
31
|
+
def get_model_snapshot_upgrade_stats(arguments = {})
|
32
|
+
raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id]
|
33
|
+
raise ArgumentError, "Required argument 'snapshot_id' missing" unless arguments[:snapshot_id]
|
34
|
+
|
35
|
+
headers = arguments.delete(:headers) || {}
|
36
|
+
|
37
|
+
body = nil
|
38
|
+
|
39
|
+
arguments = arguments.clone
|
40
|
+
|
41
|
+
_job_id = arguments.delete(:job_id)
|
42
|
+
|
43
|
+
_snapshot_id = arguments.delete(:snapshot_id)
|
44
|
+
|
45
|
+
method = Elasticsearch::API::HTTP_GET
|
46
|
+
path = "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/model_snapshots/#{Utils.__listify(_snapshot_id)}/_upgrade/_stats"
|
47
|
+
params = Utils.process_params(arguments)
|
48
|
+
|
49
|
+
Elasticsearch::API::Response.new(
|
50
|
+
perform_request(method, path, params, body, headers)
|
51
|
+
)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -23,6 +23,7 @@ module Elasticsearch
|
|
23
23
|
#
|
24
24
|
# @option arguments [String] :job_id The ID of the job to open
|
25
25
|
# @option arguments [Hash] :headers Custom HTTP headers
|
26
|
+
# @option arguments [Hash] :body Query parameters can be specified in the body
|
26
27
|
#
|
27
28
|
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html
|
28
29
|
#
|
@@ -31,7 +32,7 @@ module Elasticsearch
|
|
31
32
|
|
32
33
|
headers = arguments.delete(:headers) || {}
|
33
34
|
|
34
|
-
body =
|
35
|
+
body = arguments.delete(:body)
|
35
36
|
|
36
37
|
arguments = arguments.clone
|
37
38
|
|
@@ -26,17 +26,11 @@ module Elasticsearch
|
|
26
26
|
# support SLA of official GA features.
|
27
27
|
#
|
28
28
|
# @option arguments [List] :index The indices or index-pattern(s) (containing rollup or regular data) that should be searched
|
29
|
-
# @option arguments [String] :type The doc type inside the index *Deprecated*
|
30
29
|
# @option arguments [Boolean] :typed_keys Specify whether aggregation and suggester names should be prefixed by their respective types in the response
|
31
30
|
# @option arguments [Boolean] :rest_total_hits_as_int Indicates whether hits.total should be rendered as an integer or an object in the rest search response
|
32
31
|
# @option arguments [Hash] :headers Custom HTTP headers
|
33
32
|
# @option arguments [Hash] :body The search request body (*Required*)
|
34
33
|
#
|
35
|
-
# *Deprecation notice*:
|
36
|
-
# Specifying types in urls has been deprecated
|
37
|
-
# Deprecated since version 7.0.0
|
38
|
-
#
|
39
|
-
#
|
40
34
|
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-search.html
|
41
35
|
#
|
42
36
|
def rollup_search(arguments = {})
|
@@ -51,14 +45,8 @@ module Elasticsearch
|
|
51
45
|
|
52
46
|
_index = arguments.delete(:index)
|
53
47
|
|
54
|
-
_type = arguments.delete(:type)
|
55
|
-
|
56
48
|
method = Elasticsearch::API::HTTP_POST
|
57
|
-
path =
|
58
|
-
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_rollup_search"
|
59
|
-
else
|
60
|
-
"#{Utils.__listify(_index)}/_rollup_search"
|
61
|
-
end
|
49
|
+
path = "#{Utils.__listify(_index)}/_rollup_search"
|
62
50
|
params = Utils.process_params(arguments)
|
63
51
|
|
64
52
|
Elasticsearch::API::Response.new(
|
@@ -23,6 +23,7 @@ module Elasticsearch
|
|
23
23
|
#
|
24
24
|
# @option arguments [String] :transform_id The id of the transform to delete
|
25
25
|
# @option arguments [Boolean] :force When `true`, the transform is deleted regardless of its current state. The default value is `false`, meaning that the transform must be `stopped` before it can be deleted.
|
26
|
+
# @option arguments [Time] :timeout Controls the time to wait for the transform deletion
|
26
27
|
# @option arguments [Hash] :headers Custom HTTP headers
|
27
28
|
#
|
28
29
|
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-transform.html
|
@@ -22,6 +22,7 @@ module Elasticsearch
|
|
22
22
|
# Previews a transform.
|
23
23
|
#
|
24
24
|
# @option arguments [String] :transform_id The id of the transform to preview.
|
25
|
+
# @option arguments [Time] :timeout Controls the time to wait for the preview
|
25
26
|
# @option arguments [Hash] :headers Custom HTTP headers
|
26
27
|
# @option arguments [Hash] :body The definition for the transform to preview
|
27
28
|
#
|
@@ -47,7 +48,7 @@ module Elasticsearch
|
|
47
48
|
else
|
48
49
|
"_transform/_preview"
|
49
50
|
end
|
50
|
-
params =
|
51
|
+
params = Utils.process_params(arguments)
|
51
52
|
|
52
53
|
Elasticsearch::API::Response.new(
|
53
54
|
perform_request(method, path, params, body, headers)
|
@@ -23,6 +23,7 @@ module Elasticsearch
|
|
23
23
|
#
|
24
24
|
# @option arguments [String] :transform_id The id of the new transform.
|
25
25
|
# @option arguments [Boolean] :defer_validation If validations should be deferred until transform starts, defaults to false.
|
26
|
+
# @option arguments [Time] :timeout Controls the time to wait for the transform to start
|
26
27
|
# @option arguments [Hash] :headers Custom HTTP headers
|
27
28
|
# @option arguments [Hash] :body The transform definition (*Required*)
|
28
29
|
#
|
@@ -23,6 +23,7 @@ module Elasticsearch
|
|
23
23
|
#
|
24
24
|
# @option arguments [String] :transform_id The id of the transform. (*Required*)
|
25
25
|
# @option arguments [Boolean] :defer_validation If validations should be deferred until transform starts, defaults to false.
|
26
|
+
# @option arguments [Time] :timeout Controls the time to wait for the update
|
26
27
|
# @option arguments [Hash] :headers Custom HTTP headers
|
27
28
|
# @option arguments [Hash] :body The update transform definition (*Required*)
|
28
29
|
#
|
@@ -22,6 +22,7 @@ module Elasticsearch
|
|
22
22
|
# Upgrades all transforms.
|
23
23
|
#
|
24
24
|
# @option arguments [Boolean] :dry_run Whether to only check for updates but don't execute
|
25
|
+
# @option arguments [Time] :timeout Controls the time to wait for the upgrade
|
25
26
|
# @option arguments [Hash] :headers Custom HTTP headers
|
26
27
|
#
|
27
28
|
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/upgrade-transforms.html
|
@@ -22,7 +22,6 @@ module Elasticsearch
|
|
22
22
|
#
|
23
23
|
# @option arguments [String] :id Document ID
|
24
24
|
# @option arguments [String] :index The name of the index
|
25
|
-
# @option arguments [String] :type The type of the document *Deprecated*
|
26
25
|
# @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)
|
27
26
|
# @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return
|
28
27
|
# @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field
|
@@ -38,11 +37,6 @@ module Elasticsearch
|
|
38
37
|
# @option arguments [Hash] :headers Custom HTTP headers
|
39
38
|
# @option arguments [Hash] :body The request definition requires either `script` or partial `doc` (*Required*)
|
40
39
|
#
|
41
|
-
# *Deprecation notice*:
|
42
|
-
# Specifying types in urls has been deprecated
|
43
|
-
# Deprecated since version 7.0.0
|
44
|
-
#
|
45
|
-
#
|
46
40
|
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html
|
47
41
|
#
|
48
42
|
def update(arguments = {})
|
@@ -60,14 +54,8 @@ module Elasticsearch
|
|
60
54
|
|
61
55
|
_index = arguments.delete(:index)
|
62
56
|
|
63
|
-
_type = arguments.delete(:type)
|
64
|
-
|
65
57
|
method = Elasticsearch::API::HTTP_POST
|
66
|
-
path =
|
67
|
-
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_update"
|
68
|
-
else
|
69
|
-
"#{Utils.__listify(_index)}/_update/#{Utils.__listify(_id)}"
|
70
|
-
end
|
58
|
+
path = "#{Utils.__listify(_index)}/_update/#{Utils.__listify(_id)}"
|
71
59
|
params = Utils.process_params(arguments)
|
72
60
|
|
73
61
|
if Array(arguments[:ignore]).include?(404)
|
@@ -41,9 +41,6 @@ module Elasticsearch
|
|
41
41
|
# @option arguments [Time] :search_timeout Explicit timeout for each search request. Defaults to no timeout.
|
42
42
|
# @option arguments [Number] :max_docs Maximum number of documents to process (default: all documents)
|
43
43
|
# @option arguments [List] :sort A comma-separated list of <field>:<direction> pairs
|
44
|
-
# @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return
|
45
|
-
# @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field
|
46
|
-
# @option arguments [List] :_source_includes A list of fields to extract and return from the _source field
|
47
44
|
# @option arguments [Number] :terminate_after The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
|
48
45
|
# @option arguments [List] :stats Specific 'tag' of the request for logging and statistical purposes
|
49
46
|
# @option arguments [Boolean] :version Specify whether to return document version as part of a hit
|
@@ -14,14 +14,13 @@
|
|
14
14
|
# KIND, either express or implied. See the License for the
|
15
15
|
# specific language governing permissions and limitations
|
16
16
|
# under the License.
|
17
|
+
require 'erb'
|
17
18
|
|
18
19
|
module Elasticsearch
|
19
20
|
module API
|
20
|
-
|
21
21
|
# Generic utility methods
|
22
22
|
#
|
23
23
|
module Utils
|
24
|
-
|
25
24
|
# URL-escape a string
|
26
25
|
#
|
27
26
|
# @example
|
@@ -31,7 +30,7 @@ module Elasticsearch
|
|
31
30
|
# @api private
|
32
31
|
def __escape(string)
|
33
32
|
return string if string == '*'
|
34
|
-
|
33
|
+
ERB::Util.url_encode(string.to_s)
|
35
34
|
end
|
36
35
|
|
37
36
|
# Create a "list" of values from arguments, ignoring nil values and encoding special characters.
|
@@ -18,7 +18,6 @@
|
|
18
18
|
require 'spec_helper'
|
19
19
|
|
20
20
|
describe 'client#bulk' do
|
21
|
-
|
22
21
|
let(:expected_args) do
|
23
22
|
[
|
24
23
|
'POST',
|
@@ -35,31 +34,29 @@ describe 'client#bulk' do
|
|
35
34
|
let(:body) { '' }
|
36
35
|
|
37
36
|
context 'when a list of operations is provided' do
|
38
|
-
|
39
37
|
let(:body) do
|
40
38
|
<<-PAYLOAD.gsub(/^\s+/, '')
|
41
|
-
{"index":{"_index":"myindexA","
|
39
|
+
{"index":{"_index":"myindexA","_id":"1"}}
|
42
40
|
{"title":"Test"}
|
43
|
-
{"update":{"_index":"myindexB","
|
41
|
+
{"update":{"_index":"myindexB","_id":"2"}}
|
44
42
|
{"doc":{"title":"Update"}}
|
45
|
-
{"delete":{"_index":"myindexC","
|
46
|
-
{"index":{"_index":"myindexD","
|
43
|
+
{"delete":{"_index":"myindexC","_id":"3"}}
|
44
|
+
{"index":{"_index":"myindexD","_id":"1"}}
|
47
45
|
{"data":"MYDATA"}
|
48
46
|
PAYLOAD
|
49
47
|
end
|
50
48
|
|
51
49
|
it 'performs the request' do
|
52
50
|
expect(client_double.bulk(:body => [
|
53
|
-
{ :index => { :_index => 'myindexA', :
|
54
|
-
{ :update => { :_index => 'myindexB', :
|
55
|
-
{ :delete => { :_index => 'myindexC', :
|
56
|
-
{ :index => { :_index => 'myindexD', :
|
51
|
+
{ :index => { :_index => 'myindexA', :_id => '1', :data => { :title => 'Test' } } },
|
52
|
+
{ :update => { :_index => 'myindexB', :_id => '2', :data => { :doc => { :title => 'Update' } } } },
|
53
|
+
{ :delete => { :_index => 'myindexC', :_id => '3' } },
|
54
|
+
{ :index => { :_index => 'myindexD', :_id => '1', :data => { :data => 'MYDATA' } } },
|
57
55
|
])).to be_a Elasticsearch::API::Response
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
61
59
|
context 'when an index is specified' do
|
62
|
-
|
63
60
|
let(:url) { 'myindex/_bulk' }
|
64
61
|
|
65
62
|
it 'performs the request' do
|
@@ -68,22 +65,20 @@ describe 'client#bulk' do
|
|
68
65
|
end
|
69
66
|
|
70
67
|
context 'when there are data keys in the head/data payloads' do
|
71
|
-
|
72
68
|
let(:body) do
|
73
69
|
<<-PAYLOAD.gsub(/^\s+/, '')
|
74
|
-
{"update":{"_index":"myindex","
|
70
|
+
{"update":{"_index":"myindex","_id":"1"}}
|
75
71
|
{"doc":{"data":{"title":"Update"}}}
|
76
72
|
PAYLOAD
|
77
73
|
end
|
78
74
|
|
79
75
|
it 'performs the request' do
|
80
|
-
expect(client_double.bulk(body:[ { :update => { :_index => 'myindex', :
|
76
|
+
expect(client_double.bulk(body:[ { :update => { :_index => 'myindex', :_id => '1' } },
|
81
77
|
{ :doc => { :data => { :title => 'Update' } } } ])).to be_a Elasticsearch::API::Response
|
82
78
|
end
|
83
79
|
end
|
84
80
|
|
85
81
|
context 'when the payload is a string' do
|
86
|
-
|
87
82
|
let(:body) do
|
88
83
|
'foo\nbar'
|
89
84
|
end
|
@@ -94,7 +89,6 @@ describe 'client#bulk' do
|
|
94
89
|
end
|
95
90
|
|
96
91
|
context 'when the payload is an array of Strings' do
|
97
|
-
|
98
92
|
let(:body) do
|
99
93
|
"foo\nbar\n"
|
100
94
|
end
|
@@ -105,7 +99,6 @@ describe 'client#bulk' do
|
|
105
99
|
end
|
106
100
|
|
107
101
|
context 'when there are parameters' do
|
108
|
-
|
109
102
|
let(:params) do
|
110
103
|
{ refresh: true }
|
111
104
|
end
|
@@ -116,7 +109,6 @@ describe 'client#bulk' do
|
|
116
109
|
end
|
117
110
|
|
118
111
|
context 'when url characters need to be URL-escaped' do
|
119
|
-
|
120
112
|
let(:url) do
|
121
113
|
'foo%5Ebar/_bulk'
|
122
114
|
end
|
@@ -125,15 +117,4 @@ describe 'client#bulk' do
|
|
125
117
|
expect(client_double.bulk(index: 'foo^bar', body: [])).to be_a Elasticsearch::API::Response
|
126
118
|
end
|
127
119
|
end
|
128
|
-
|
129
|
-
context 'when the type is provided' do
|
130
|
-
|
131
|
-
let(:url) do
|
132
|
-
'myindex/mytype/_bulk'
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'performs the request' do
|
136
|
-
expect(client_double.bulk(index: 'myindex', type: 'mytype', body: [])).to be_a Elasticsearch::API::Response
|
137
|
-
end
|
138
|
-
end
|
139
120
|
end
|
@@ -18,10 +18,9 @@
|
|
18
18
|
require 'spec_helper'
|
19
19
|
|
20
20
|
describe 'client#count' do
|
21
|
-
|
22
21
|
let(:expected_args) do
|
23
22
|
[
|
24
|
-
'
|
23
|
+
'GET',
|
25
24
|
'_count',
|
26
25
|
{},
|
27
26
|
nil,
|
@@ -34,10 +33,9 @@ describe 'client#count' do
|
|
34
33
|
end
|
35
34
|
|
36
35
|
context 'when an index and type are specified' do
|
37
|
-
|
38
36
|
let(:expected_args) do
|
39
37
|
[
|
40
|
-
'
|
38
|
+
'GET',
|
41
39
|
'foo,bar/_count',
|
42
40
|
{},
|
43
41
|
nil,
|
@@ -51,7 +49,6 @@ describe 'client#count' do
|
|
51
49
|
end
|
52
50
|
|
53
51
|
context 'when there is a query provided' do
|
54
|
-
|
55
52
|
let(:expected_args) do
|
56
53
|
[
|
57
54
|
'POST',
|
@@ -22,7 +22,7 @@ describe 'client#delete' do
|
|
22
22
|
let(:expected_args) do
|
23
23
|
[
|
24
24
|
'DELETE',
|
25
|
-
'foo/
|
25
|
+
'foo/_doc/1',
|
26
26
|
params,
|
27
27
|
nil,
|
28
28
|
{}
|
@@ -39,18 +39,18 @@ describe 'client#delete' do
|
|
39
39
|
|
40
40
|
it 'requires the :index argument' do
|
41
41
|
expect {
|
42
|
-
client.delete(
|
42
|
+
client.delete(id: '1')
|
43
43
|
}.to raise_exception(ArgumentError)
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'requires the :id argument' do
|
47
47
|
expect {
|
48
|
-
client.delete(index: 'foo'
|
48
|
+
client.delete(index: 'foo')
|
49
49
|
}.to raise_exception(ArgumentError)
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'performs the request' do
|
53
|
-
expect(client_double.delete(index: 'foo',
|
53
|
+
expect(client_double.delete(index: 'foo', id: '1')).to be_a Elasticsearch::API::Response
|
54
54
|
end
|
55
55
|
|
56
56
|
context 'when url params are provided' do
|
@@ -59,7 +59,7 @@ describe 'client#delete' do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'performs the request' do
|
62
|
-
expect(client_double.delete(index: 'foo',
|
62
|
+
expect(client_double.delete(index: 'foo', id: '1', routing: 'abc123')).to be_a Elasticsearch::API::Response
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -67,7 +67,7 @@ describe 'client#delete' do
|
|
67
67
|
let(:expected_args) do
|
68
68
|
[
|
69
69
|
'DELETE',
|
70
|
-
'foo%5Ebar/
|
70
|
+
'foo%5Ebar/_doc/1',
|
71
71
|
params,
|
72
72
|
nil,
|
73
73
|
{}
|
@@ -75,7 +75,7 @@ describe 'client#delete' do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'escapes the url params' do
|
78
|
-
expect(client_double.delete(index: 'foo^bar',
|
78
|
+
expect(client_double.delete(index: 'foo^bar', id: 1)).to be_a Elasticsearch::API::Response
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -86,13 +86,13 @@ describe 'client#delete' do
|
|
86
86
|
|
87
87
|
it 'raises the exception' do
|
88
88
|
expect {
|
89
|
-
client.delete(index: 'foo',
|
89
|
+
client.delete(index: 'foo', id: 'XXX')
|
90
90
|
}.to raise_exception(NotFound)
|
91
91
|
end
|
92
92
|
|
93
93
|
context 'when the :ignore option is provided' do
|
94
94
|
it 'does not raise the NotFound exception' do
|
95
|
-
expect(client.delete(index: 'foo',
|
95
|
+
expect(client.delete(index: 'foo', id: 1, ignore: 404)).to eq(false)
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
@@ -55,16 +55,6 @@ describe 'client.cluster#validate_query' do
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
context 'when a type and index are specified' do
|
59
|
-
let(:url) do
|
60
|
-
'foo/bar/_validate/query'
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'performs the request' do
|
64
|
-
expect(client_double.indices.validate_query(index: 'foo', type: 'bar')).to be_a Elasticsearch::API::Response
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
58
|
context 'when multiple indicies are specified as a list' do
|
69
59
|
let(:url) do
|
70
60
|
'foo,bar/_validate/query'
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
18
|
+
require 'spec_helper'
|
19
|
+
|
20
|
+
describe 'client#ml.get_model_snapshot_upgrade_stats' do
|
21
|
+
let(:expected_args) do
|
22
|
+
[
|
23
|
+
'GET',
|
24
|
+
'_ml/anomaly_detectors/foo/model_snapshots/bar/_upgrade/_stats',
|
25
|
+
{},
|
26
|
+
nil,
|
27
|
+
{}
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'performs the request' do
|
32
|
+
expect(
|
33
|
+
client_double.ml.get_model_snapshot_upgrade_stats(job_id: 'foo', snapshot_id: 'bar')
|
34
|
+
).to be_a Elasticsearch::API::Response
|
35
|
+
end
|
36
|
+
|
37
|
+
let(:client) do
|
38
|
+
Class.new { include Elasticsearch::API }.new
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'when a job_id is not provided' do
|
42
|
+
it 'raises an exception' do
|
43
|
+
expect {
|
44
|
+
client.ml.get_model_snapshot_upgrade_stats(snapshot_id: 'foo')
|
45
|
+
}.to raise_exception(ArgumentError)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when a snapshot_id is not provided' do
|
50
|
+
it 'raises an exception' do
|
51
|
+
expect {
|
52
|
+
client.ml.get_model_snapshot_upgrade_stats(job_id: 'foo')
|
53
|
+
}.to raise_exception(ArgumentError)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -33,7 +33,7 @@ describe 'client#update' do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
let(:url) do
|
36
|
-
'foo/
|
36
|
+
'foo/_update/1'
|
37
37
|
end
|
38
38
|
|
39
39
|
let(:client) do
|
@@ -46,23 +46,23 @@ describe 'client#update' do
|
|
46
46
|
|
47
47
|
it 'requires the :index argument' do
|
48
48
|
expect {
|
49
|
-
client.update(
|
49
|
+
client.update(id: '1')
|
50
50
|
}.to raise_exception(ArgumentError)
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'requires the :id argument' do
|
54
54
|
expect {
|
55
|
-
client.update(index: 'foo'
|
55
|
+
client.update(index: 'foo')
|
56
56
|
}.to raise_exception(ArgumentError)
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'performs the request' do
|
60
|
-
expect(client_double.update(index: 'foo',
|
60
|
+
expect(client_double.update(index: 'foo', id: '1', body: { doc: {} })).to be_a Elasticsearch::API::Response
|
61
61
|
end
|
62
62
|
|
63
63
|
context 'when URL parameters are provided' do
|
64
64
|
let(:url) do
|
65
|
-
'foo/
|
65
|
+
'foo/_update/1'
|
66
66
|
end
|
67
67
|
|
68
68
|
let(:body) do
|
@@ -70,13 +70,13 @@ describe 'client#update' do
|
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'performs the request' do
|
73
|
-
expect(client_double.update(index: 'foo',
|
73
|
+
expect(client_double.update(index: 'foo', id: '1', body: {}))
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
context 'when the request needs to be URL-escaped' do
|
78
78
|
let(:url) do
|
79
|
-
'foo%5Ebar/
|
79
|
+
'foo%5Ebar/_update/1'
|
80
80
|
end
|
81
81
|
|
82
82
|
let(:body) do
|
@@ -84,7 +84,7 @@ describe 'client#update' do
|
|
84
84
|
end
|
85
85
|
|
86
86
|
it 'escapes the parts' do
|
87
|
-
expect(client_double.update(index: 'foo^bar',
|
87
|
+
expect(client_double.update(index: 'foo^bar', id: '1', body: {}))
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -95,13 +95,13 @@ describe 'client#update' do
|
|
95
95
|
|
96
96
|
it 'raises it to the user' do
|
97
97
|
expect {
|
98
|
-
client.update(index: 'foo',
|
98
|
+
client.update(index: 'foo', id: 'XXX', body: {})
|
99
99
|
}.to raise_exception(NotFound)
|
100
100
|
end
|
101
101
|
|
102
102
|
context 'when the :ignore parameter is specified' do
|
103
103
|
it 'does not raise the error to the user' do
|
104
|
-
expect(client.update(index: 'foo',
|
104
|
+
expect(client.update(index: 'foo', id: 'XXX', body: {}, ignore: 404)).to eq(false)
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
@@ -28,7 +28,7 @@ describe Elasticsearch::API::Utils do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'encodes special characters' do
|
31
|
-
expect(utils.__escape('foo bar')).to eq('foo
|
31
|
+
expect(utils.__escape('foo bar')).to eq('foo%20bar')
|
32
32
|
expect(utils.__escape('foo/bar')).to eq('foo%2Fbar')
|
33
33
|
expect(utils.__escape('foo^bar')).to eq('foo%5Ebar')
|
34
34
|
end
|
@@ -36,18 +36,6 @@ describe Elasticsearch::API::Utils do
|
|
36
36
|
it 'does not encode asterisks' do
|
37
37
|
expect(utils.__escape('*')).to eq('*')
|
38
38
|
end
|
39
|
-
|
40
|
-
it 'users CGI.escape by default' do
|
41
|
-
expect(CGI).to receive(:escape).and_call_original
|
42
|
-
expect(utils.__escape('foo bar')).to eq('foo+bar')
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'uses the escape_utils gem when available', unless: defined?(JRUBY_VERSION) do
|
46
|
-
require 'escape_utils'
|
47
|
-
expect(CGI).not_to receive(:escape)
|
48
|
-
expect(EscapeUtils).to receive(:escape_url).and_call_original
|
49
|
-
expect(utils.__escape('foo bar')).to eq('foo+bar')
|
50
|
-
end
|
51
39
|
end
|
52
40
|
|
53
41
|
describe '#__listify' do
|
@@ -73,7 +61,7 @@ describe Elasticsearch::API::Utils do
|
|
73
61
|
|
74
62
|
context 'when the escape option is set to false' do
|
75
63
|
it 'does not escape the characters' do
|
76
|
-
expect(utils.__listify(['foo', 'bar^bam'], :
|
64
|
+
expect(utils.__listify(['foo', 'bar^bam'], escape: false)).to eq('foo,bar^bam')
|
77
65
|
end
|
78
66
|
end
|
79
67
|
end
|
@@ -100,19 +88,19 @@ describe Elasticsearch::API::Utils do
|
|
100
88
|
context 'when the input is an array of hashes' do
|
101
89
|
let(:result) do
|
102
90
|
utils.__bulkify [
|
103
|
-
{ :
|
104
|
-
{ :
|
105
|
-
{ :
|
91
|
+
{ index: { _index: 'myindexA', _id: '1', data: { title: 'Test' } } },
|
92
|
+
{ update: { _index: 'myindexB', _id: '2', data: { doc: { title: 'Update' } } } },
|
93
|
+
{ delete: { _index: 'myindexC', _id: '3' } }
|
106
94
|
]
|
107
95
|
end
|
108
96
|
|
109
97
|
let(:expected_string) do
|
110
98
|
<<-PAYLOAD.gsub(/^\s+/, '')
|
111
|
-
{"index":{"_index":"myindexA","
|
99
|
+
{"index":{"_index":"myindexA","_id":"1"}}
|
112
100
|
{"title":"Test"}
|
113
|
-
{"update":{"_index":"myindexB","
|
101
|
+
{"update":{"_index":"myindexB","_id":"2"}}
|
114
102
|
{"doc":{"title":"Update"}}
|
115
|
-
{"delete":{"_index":"myindexC","
|
103
|
+
{"delete":{"_index":"myindexC","_id":"3"}}
|
116
104
|
PAYLOAD
|
117
105
|
end
|
118
106
|
|
@@ -316,7 +304,7 @@ describe Elasticsearch::API::Utils do
|
|
316
304
|
end
|
317
305
|
|
318
306
|
let(:unsupported_params) do
|
319
|
-
[ { :
|
307
|
+
[ { foo: { explanation: 'NOT_SUPPORTED'} }, :moo ]
|
320
308
|
end
|
321
309
|
|
322
310
|
|
data/spec/skipped_tests_free.yml
CHANGED
@@ -22,3 +22,11 @@
|
|
22
22
|
-
|
23
23
|
:file: 'indices.get_alias/10_basic.yml'
|
24
24
|
:description: 'Get alias against closed indices'
|
25
|
+
|
26
|
+
# https://github.com/elastic/elasticsearch-ruby/issues/1563
|
27
|
+
-
|
28
|
+
:file: 'tsdb/80_index_resize.yml'
|
29
|
+
:description: 'shrink'
|
30
|
+
-
|
31
|
+
:file: 'tsdb/80_index_resize.yml'
|
32
|
+
:description: 'clone'
|
data/spec/spec_helper.rb
CHANGED
@@ -136,6 +136,7 @@ module Elasticsearch
|
|
136
136
|
|
137
137
|
def __http_method
|
138
138
|
return '_id ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST' if @endpoint_name == 'index'
|
139
|
+
return post_and_get if @endpoint_name == 'count'
|
139
140
|
|
140
141
|
default_method = @spec['url']['paths'].map { |a| a['methods'] }.flatten.first
|
141
142
|
if @spec['body'] && default_method == 'GET'
|
@@ -143,20 +144,24 @@ module Elasticsearch
|
|
143
144
|
if @spec['body']['required']
|
144
145
|
'Elasticsearch::API::HTTP_POST'
|
145
146
|
else
|
146
|
-
|
147
|
-
<<~SRC
|
148
|
-
if body
|
149
|
-
Elasticsearch::API::HTTP_POST
|
150
|
-
else
|
151
|
-
Elasticsearch::API::HTTP_GET
|
152
|
-
end
|
153
|
-
SRC
|
147
|
+
post_and_get
|
154
148
|
end
|
155
149
|
else
|
156
150
|
"Elasticsearch::API::HTTP_#{default_method}"
|
157
151
|
end
|
158
152
|
end
|
159
153
|
|
154
|
+
def post_and_get
|
155
|
+
# the METHOD is defined after doing arguments.delete(:body), so we need to check for `body`
|
156
|
+
<<~SRC
|
157
|
+
if body
|
158
|
+
Elasticsearch::API::HTTP_POST
|
159
|
+
else
|
160
|
+
Elasticsearch::API::HTTP_GET
|
161
|
+
end
|
162
|
+
SRC
|
163
|
+
end
|
164
|
+
|
160
165
|
def __http_path
|
161
166
|
return "\"#{__parse_path(@paths.first)}\"" if @paths.size == 1
|
162
167
|
|
@@ -182,9 +187,9 @@ module Elasticsearch
|
|
182
187
|
|
183
188
|
def __parse_path(path)
|
184
189
|
path.gsub(/^\//, '')
|
185
|
-
|
186
|
-
|
187
|
-
|
190
|
+
.gsub(/\/$/, '')
|
191
|
+
.gsub('{', "\#{Utils.__listify(_")
|
192
|
+
.gsub('}', ')}')
|
188
193
|
end
|
189
194
|
|
190
195
|
def __path_variables
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.0.0
|
4
|
+
version: 8.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karel Minarik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -193,7 +193,7 @@ dependencies:
|
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
|
-
name:
|
196
|
+
name: activesupport
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
199
|
- - ">="
|
@@ -207,7 +207,7 @@ dependencies:
|
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
|
-
name:
|
210
|
+
name: jbuilder
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
213
|
- - ">="
|
@@ -221,7 +221,21 @@ dependencies:
|
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0'
|
223
223
|
- !ruby/object:Gem::Dependency
|
224
|
-
name:
|
224
|
+
name: cane
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: escape_utils
|
225
239
|
requirement: !ruby/object:Gem::Requirement
|
226
240
|
requirements:
|
227
241
|
- - ">="
|
@@ -534,6 +548,7 @@ files:
|
|
534
548
|
- lib/elasticsearch/api/actions/machine_learning/get_influencers.rb
|
535
549
|
- lib/elasticsearch/api/actions/machine_learning/get_job_stats.rb
|
536
550
|
- lib/elasticsearch/api/actions/machine_learning/get_jobs.rb
|
551
|
+
- lib/elasticsearch/api/actions/machine_learning/get_model_snapshot_upgrade_stats.rb
|
537
552
|
- lib/elasticsearch/api/actions/machine_learning/get_model_snapshots.rb
|
538
553
|
- lib/elasticsearch/api/actions/machine_learning/get_overall_buckets.rb
|
539
554
|
- lib/elasticsearch/api/actions/machine_learning/get_records.rb
|
@@ -858,6 +873,7 @@ files:
|
|
858
873
|
- spec/elasticsearch/api/actions/ingest/put_pipeline_spec.rb
|
859
874
|
- spec/elasticsearch/api/actions/ingest/simulate_spec.rb
|
860
875
|
- spec/elasticsearch/api/actions/json_builders_spec.rb
|
876
|
+
- spec/elasticsearch/api/actions/machine_learning/get_model_snapshot_upgrade_stats_spec.rb
|
861
877
|
- spec/elasticsearch/api/actions/machine_learning/get_trained_model_deployment_stats_spec.rb
|
862
878
|
- spec/elasticsearch/api/actions/machine_learning/infer_trained_model_deployment_spec.rb
|
863
879
|
- spec/elasticsearch/api/actions/machine_learning/put_trained_model_definition_part_spec.rb
|
@@ -1099,11 +1115,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1099
1115
|
version: '2.5'
|
1100
1116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1101
1117
|
requirements:
|
1102
|
-
- - "
|
1118
|
+
- - ">="
|
1103
1119
|
- !ruby/object:Gem::Version
|
1104
|
-
version:
|
1120
|
+
version: '0'
|
1105
1121
|
requirements: []
|
1106
|
-
rubygems_version: 3.
|
1122
|
+
rubygems_version: 3.3.3
|
1107
1123
|
signing_key:
|
1108
1124
|
specification_version: 4
|
1109
1125
|
summary: Ruby API for Elasticsearch.
|
@@ -1207,6 +1223,7 @@ test_files:
|
|
1207
1223
|
- spec/elasticsearch/api/actions/ingest/put_pipeline_spec.rb
|
1208
1224
|
- spec/elasticsearch/api/actions/ingest/simulate_spec.rb
|
1209
1225
|
- spec/elasticsearch/api/actions/json_builders_spec.rb
|
1226
|
+
- spec/elasticsearch/api/actions/machine_learning/get_model_snapshot_upgrade_stats_spec.rb
|
1210
1227
|
- spec/elasticsearch/api/actions/machine_learning/get_trained_model_deployment_stats_spec.rb
|
1211
1228
|
- spec/elasticsearch/api/actions/machine_learning/infer_trained_model_deployment_spec.rb
|
1212
1229
|
- spec/elasticsearch/api/actions/machine_learning/put_trained_model_definition_part_spec.rb
|