Skip to content

Commit a6af2d0

Browse files
committed
[API] Updates scroll and clear_scroll endpoints
Since sending the `scroll_id` as a parameter was deprecated, now it needs to be sent in the body for `clear_scroll`, `scroll`.
1 parent 949f365 commit a6af2d0

File tree

2 files changed

+27
-33
lines changed

2 files changed

+27
-33
lines changed

elasticsearch-api/lib/elasticsearch/api/actions/clear_scroll.rb

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,25 @@
2121
module Elasticsearch
2222
module API
2323
module Actions
24-
# Explicitly clears the search context for a scroll.
24+
# Clear a scrolling search.
25+
# Clear the search context and results for a scrolling search.
2526
#
26-
# @option arguments [List] :scroll_id A comma-separated list of scroll IDs to clear *Deprecated*
27+
# @option arguments [String, Array] :scroll_id A comma-separated list of scroll IDs to clear.
28+
# To clear all scroll IDs, use +_all+.
29+
# IMPORTANT: Scroll IDs can be long. It is recommended to specify scroll IDs in the request body parameter.
2730
# @option arguments [Hash] :headers Custom HTTP headers
28-
# @option arguments [Hash] :body A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter
31+
# @option arguments [Hash] :body request body
2932
#
3033
# *Deprecation notice*:
3134
# A scroll id can be quite large and should be specified as part of the body
3235
# Deprecated since version 7.0.0
3336
#
3437
#
35-
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-scroll-api.html
38+
# @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-clear-scroll
3639
#
3740
def clear_scroll(arguments = {})
3841
request_opts = { endpoint: arguments[:endpoint] || 'clear_scroll' }
3942

40-
defined_params = [:scroll_id].each_with_object({}) do |variable, set_variables|
41-
set_variables[variable] = arguments[variable] if arguments.key?(variable)
42-
end
43-
request_opts[:defined_params] = defined_params unless defined_params.empty?
44-
4543
arguments = arguments.clone
4644
headers = arguments.delete(:headers) || {}
4745

@@ -50,15 +48,11 @@ def clear_scroll(arguments = {})
5048
_scroll_id = arguments.delete(:scroll_id)
5149

5250
method = Elasticsearch::API::HTTP_DELETE
53-
path = if _scroll_id
54-
"_search/scroll/#{Utils.__listify(_scroll_id)}"
55-
else
56-
'_search/scroll'
57-
end
51+
path = '_search/scroll'
5852
params = Utils.process_params(arguments)
5953

6054
if Array(arguments[:ignore]).include?(404)
61-
Utils.__rescue_from_not_found do
55+
Utils.rescue_from_not_found do
6256
Elasticsearch::API::Response.new(
6357
perform_request(method, path, params, body, headers, request_opts)
6458
)

elasticsearch-api/lib/elasticsearch/api/actions/scroll.rb

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,39 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
#
18-
# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80
19-
# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec
18+
# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80
19+
# @see https://github.com/elastic/elasticsearch-specification
2020
#
2121
module Elasticsearch
2222
module API
2323
module Actions
24-
# Allows to retrieve a large numbers of results from a single search request.
24+
# Run a scrolling search.
25+
# IMPORTANT: The scroll API is no longer recommend for deep pagination. If you need to preserve the index state while paging through more than 10,000 hits, use the +search_after+ parameter with a point in time (PIT).
26+
# The scroll API gets large sets of results from a single scrolling search request.
27+
# To get the necessary scroll ID, submit a search API request that includes an argument for the +scroll+ query parameter.
28+
# The +scroll+ parameter indicates how long Elasticsearch should retain the search context for the request.
29+
# The search response returns a scroll ID in the +_scroll_id+ response body parameter.
30+
# You can then use the scroll ID with the scroll API to retrieve the next batch of results for the request.
31+
# If the Elasticsearch security features are enabled, the access to the results of a specific scroll ID is restricted to the user or API key that submitted the search.
32+
# You can also use the scroll API to specify a new scroll parameter that extends or shortens the retention period for the search context.
33+
# IMPORTANT: Results from a scrolling search reflect the state of the index at the time of the initial search request. Subsequent indexing or document changes only affect later search and scroll requests.
2534
#
26-
# @option arguments [String] :scroll_id The scroll ID *Deprecated*
27-
# @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search
28-
# @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
35+
# @option arguments [String] :scroll_id The scroll ID
36+
# @option arguments [Time] :scroll The period to retain the search context for scrolling. Server default: 1d.
37+
# @option arguments [Boolean] :rest_total_hits_as_int If true, the API response’s hit.total property is returned as an integer. If false, the API response’s hit.total property is returned as an object.
2938
# @option arguments [Hash] :headers Custom HTTP headers
30-
# @option arguments [Hash] :body The scroll ID if not passed by URL or query parameter.
39+
# @option arguments [Hash] :body request body
3140
#
3241
# *Deprecation notice*:
3342
# A scroll id can be quite large and should be specified as part of the body
3443
# Deprecated since version 7.0.0
3544
#
3645
#
37-
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#request-body-search-scroll
46+
# @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-scroll
3847
#
3948
def scroll(arguments = {})
4049
request_opts = { endpoint: arguments[:endpoint] || 'scroll' }
4150

42-
defined_params = [:scroll_id].each_with_object({}) do |variable, set_variables|
43-
set_variables[variable] = arguments[variable] if arguments.key?(variable)
44-
end
45-
request_opts[:defined_params] = defined_params unless defined_params.empty?
46-
4751
arguments = arguments.clone
4852
headers = arguments.delete(:headers) || {}
4953

@@ -57,11 +61,7 @@ def scroll(arguments = {})
5761
Elasticsearch::API::HTTP_GET
5862
end
5963

60-
path = if _scroll_id
61-
"_search/scroll/#{Utils.__listify(_scroll_id)}"
62-
else
63-
'_search/scroll'
64-
end
64+
path = '_search/scroll'
6565
params = Utils.process_params(arguments)
6666

6767
Elasticsearch::API::Response.new(

0 commit comments

Comments
 (0)