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,21 +5,23 @@
|
|
5
5
|
module Elasticsearch
|
6
6
|
module API
|
7
7
|
module Actions
|
8
|
-
|
9
|
-
# The Painless execute API allows an arbitrary script to be executed and a result to be returned.
|
8
|
+
# Allows an arbitrary script to be executed and a result to be returned
|
10
9
|
#
|
10
|
+
|
11
11
|
# @option arguments [Hash] :body The script to execute
|
12
12
|
#
|
13
|
-
# @see https://www.elastic.co/guide/en/elasticsearch/painless/
|
13
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/painless/7.5/painless-execute-api.html
|
14
14
|
#
|
15
|
-
def scripts_painless_execute(arguments={})
|
15
|
+
def scripts_painless_execute(arguments = {})
|
16
|
+
arguments = arguments.clone
|
17
|
+
|
16
18
|
method = Elasticsearch::API::HTTP_GET
|
17
19
|
path = "_scripts/painless/_execute"
|
18
20
|
params = {}
|
19
|
-
body = arguments[:body]
|
20
21
|
|
22
|
+
body = arguments[:body]
|
21
23
|
perform_request(method, path, params, body).body
|
22
24
|
end
|
23
25
|
end
|
24
|
-
|
26
|
+
end
|
25
27
|
end
|
@@ -5,70 +5,47 @@
|
|
5
5
|
module Elasticsearch
|
6
6
|
module API
|
7
7
|
module Actions
|
8
|
-
|
9
|
-
# Efficiently iterate over a large result set.
|
10
|
-
#
|
11
|
-
# When using `from` and `size` to return a large result sets, performance drops as you "paginate" in the set,
|
12
|
-
# and you can't guarantee the consistency when the index is being updated at the same time.
|
13
|
-
#
|
14
|
-
# The "Scroll" API uses a "point in time" snapshot of the index state, which was created via a "Search" API
|
15
|
-
# request specifying the `scroll` parameter.
|
16
|
-
#
|
17
|
-
# @example A basic example
|
18
|
-
#
|
19
|
-
# result = client.search index: 'scrollindex',
|
20
|
-
# scroll: '5m',
|
21
|
-
# body: { query: { match: { title: 'test' } }, sort: '_id' }
|
22
|
-
#
|
23
|
-
# result = client.scroll body: { scroll_id: result['_scroll_id'], scroll: '5m' }
|
24
|
-
#
|
25
|
-
# @example Call the `scroll` API until all the documents are returned
|
26
|
-
#
|
27
|
-
# # Index 1,000 documents
|
28
|
-
# client.indices.delete index: 'test'
|
29
|
-
# 1_000.times do |i| client.index index: 'test', type: 'test', id: i+1, body: {title: "Test #{i+1}"} end
|
30
|
-
# client.indices.refresh index: 'test'
|
31
|
-
#
|
32
|
-
# # Open the "view" of the index by passing the `scroll` parameter
|
33
|
-
# # Sorting by `_doc` makes the operations faster
|
34
|
-
# r = client.search index: 'test', scroll: '1m', body: {sort: ['_doc']}
|
35
|
-
#
|
36
|
-
# # Display the initial results
|
37
|
-
# puts "--- BATCH 0 -------------------------------------------------"
|
38
|
-
# puts r['hits']['hits'].map { |d| d['_source']['title'] }.inspect
|
8
|
+
# Allows to retrieve a large numbers of results from a single search request.
|
39
9
|
#
|
40
|
-
#
|
41
|
-
# while r = client.scroll(body: { scroll_id: r['_scroll_id'] }, scroll: '5m') and not r['hits']['hits'].empty? do
|
42
|
-
# puts "--- BATCH #{defined?($i) ? $i += 1 : $i = 1} -------------------------------------------------"
|
43
|
-
# puts r['hits']['hits'].map { |d| d['_source']['title'] }.inspect
|
44
|
-
# puts
|
45
|
-
# end
|
46
|
-
#
|
47
|
-
# @option arguments [String] :scroll_id The scroll ID
|
48
|
-
# @option arguments [Hash] :body The scroll ID if not passed by URL or query parameter.
|
10
|
+
# @option arguments [String] :scroll_id The scroll ID *Deprecated*
|
49
11
|
# @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search
|
50
12
|
# @option arguments [String] :scroll_id The scroll ID for scrolled search
|
51
13
|
# @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
|
14
|
+
|
15
|
+
# @option arguments [Hash] :body The scroll ID if not passed by URL or query parameter.
|
16
|
+
#
|
17
|
+
# *Deprecation notice*:
|
18
|
+
# A scroll id can be quite large and should be specified as part of the body
|
19
|
+
# Deprecated since version 7.0.0
|
52
20
|
#
|
53
|
-
# @see https://www.elastic.co/guide/en/elasticsearch/guide/current/scan-scroll.html#scan-scroll
|
54
|
-
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html
|
55
21
|
#
|
56
|
-
|
57
|
-
|
58
|
-
|
22
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-request-body.html#request-body-search-scroll
|
23
|
+
#
|
24
|
+
def scroll(arguments = {})
|
25
|
+
arguments = arguments.clone
|
26
|
+
|
27
|
+
_scroll_id = arguments.delete(:scroll_id)
|
28
|
+
|
29
|
+
method = Elasticsearch::API::HTTP_GET
|
30
|
+
path = if _scroll_id
|
31
|
+
"_search/scroll/#{Utils.__listify(_scroll_id)}"
|
32
|
+
else
|
33
|
+
"_search/scroll"
|
34
|
+
end
|
59
35
|
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
60
|
-
body = arguments[:body]
|
61
36
|
|
37
|
+
body = arguments[:body]
|
62
38
|
perform_request(method, path, params, body).body
|
63
39
|
end
|
64
40
|
|
65
41
|
# Register this action with its valid params when the module is loaded.
|
66
42
|
#
|
67
|
-
# @since 6.
|
43
|
+
# @since 6.2.0
|
68
44
|
ParamsRegistry.register(:scroll, [
|
69
|
-
|
70
|
-
|
71
|
-
|
45
|
+
:scroll,
|
46
|
+
:scroll_id,
|
47
|
+
:rest_total_hits_as_int
|
48
|
+
].freeze)
|
49
|
+
end
|
72
50
|
end
|
73
|
-
end
|
74
51
|
end
|
@@ -5,200 +5,139 @@
|
|
5
5
|
module Elasticsearch
|
6
6
|
module API
|
7
7
|
module Actions
|
8
|
-
|
9
|
-
# Return documents matching a query, as well as aggregations (facets), highlighted snippets, suggestions, etc.
|
10
|
-
#
|
11
|
-
# The search API is used to query one or more indices either using simple
|
12
|
-
# [query string queries](https://www.elastic.co/guide/reference/api/search/uri-request/)
|
13
|
-
# as the `:q` argument , or by passing the
|
14
|
-
# [full request definition](https://www.elastic.co/guide/reference/api/search/request-body/)
|
15
|
-
# in the [Query DSL](https://www.elastic.co/guide/reference/query-dsl/) as the `:body` argument.
|
16
|
-
#
|
17
|
-
# @example Search with a simple query string query
|
18
|
-
#
|
19
|
-
# client.search index: 'myindex', q: 'title:test'
|
20
|
-
#
|
21
|
-
# @example Passing a full request definition in the Elasticsearch's Query DSL as a `Hash`
|
22
|
-
#
|
23
|
-
# client.search index: 'myindex',
|
24
|
-
# body: {
|
25
|
-
# query: { match: { title: 'test' } },
|
26
|
-
# aggregations: { tags: { terms: { field: 'tags' } } }
|
27
|
-
# }
|
28
|
-
#
|
29
|
-
# @example Paginating results: return 10 documents, beginning from the 10th
|
30
|
-
#
|
31
|
-
# client.search index: 'myindex',
|
32
|
-
# body: {
|
33
|
-
# query: { match: { title: 'test' } },
|
34
|
-
# from: 10,
|
35
|
-
# size: 10
|
36
|
-
# }
|
37
|
-
#
|
38
|
-
# @example Passing the search definition as a `String`, built with a JSON builder
|
39
|
-
#
|
40
|
-
# require 'jbuilder'
|
41
|
-
#
|
42
|
-
# json = Jbuilder.encode do |json|
|
43
|
-
# json.query do
|
44
|
-
# json.match do
|
45
|
-
# json.title do
|
46
|
-
# json.query 'test 1'
|
47
|
-
# json.operator 'and'
|
48
|
-
# end
|
49
|
-
# end
|
50
|
-
# end
|
51
|
-
# end
|
52
|
-
#
|
53
|
-
# client.search index: 'myindex', body: json
|
54
|
-
#
|
55
|
-
# @example Wrapping the result in [`Hashie::Mash`](https://github.com/intridea/hashie) for easier access
|
56
|
-
#
|
57
|
-
# response = client.search index: 'myindex',
|
58
|
-
# body: {
|
59
|
-
# query: { match: { title: 'test' } },
|
60
|
-
# aggregations: { tags: { terms: { field: 'tags' } } }
|
61
|
-
# }
|
62
|
-
#
|
63
|
-
# response = Hashie::Mash.new response
|
8
|
+
# Returns results matching a query.
|
64
9
|
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
# response.aggregations.tags.terms.to_a.map { |f| "#{f.term} [#{f.count}]" }.join(', ')
|
68
|
-
#
|
69
|
-
# @option arguments [List] :index A comma-separated list of index names to search; use `_all`
|
70
|
-
# or empty string to perform the operation on all indices
|
71
|
-
# @option arguments [List] :type A comma-separated list of document types to search;
|
72
|
-
# leave empty to perform the operation on all types
|
73
|
-
# @option arguments [Hash] :body The search definition using the Query DSL
|
10
|
+
# @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] :type A comma-separated list of document types to search; leave empty to perform the operation on all types
|
74
12
|
# @option arguments [String] :analyzer The analyzer to use for the query string
|
75
|
-
# @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed
|
76
|
-
#
|
13
|
+
# @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false)
|
14
|
+
# @option arguments [Boolean] :ccs_minimize_roundtrips Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
|
77
15
|
# @option arguments [String] :default_operator The default operator for query string query (AND or OR)
|
78
|
-
#
|
16
|
+
# (options: AND,OR)
|
17
|
+
|
79
18
|
# @option arguments [String] :df The field to use as default where no field prefix is given in the query string
|
80
|
-
# @option arguments [Boolean] :explain Specify whether to return detailed information about score computation
|
81
|
-
# as part of a hit
|
82
|
-
# @option arguments [List] :fields A comma-separated list of fields to return as part of a hit
|
83
|
-
# @option arguments [List] :fielddata_fields A comma-separated list of fields to return as the field data
|
84
|
-
# representation of a field for each hit
|
85
|
-
# @option arguments [List] :docvalue_fields A comma-separated list of fields to return as the docvalue
|
86
|
-
# representation of a field for each hit
|
19
|
+
# @option arguments [Boolean] :explain Specify whether to return detailed information about score computation as part of a hit
|
87
20
|
# @option arguments [List] :stored_fields A comma-separated list of stored fields to return as part of a hit
|
21
|
+
# @option arguments [List] :docvalue_fields A comma-separated list of fields to return as the docvalue representation of a field for each hit
|
88
22
|
# @option arguments [Number] :from Starting offset (default: 0)
|
89
|
-
# @option arguments [Boolean] :
|
90
|
-
# @option arguments [
|
91
|
-
#
|
92
|
-
# @option arguments [
|
93
|
-
#
|
94
|
-
|
95
|
-
# @option arguments [
|
96
|
-
#
|
23
|
+
# @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
24
|
+
# @option arguments [Boolean] :ignore_throttled Whether specified concrete, expanded or aliased indices should be ignored when throttled
|
25
|
+
# @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)
|
26
|
+
# @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
27
|
+
# (options: open,closed,none,all)
|
28
|
+
|
29
|
+
# @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
|
30
|
+
# @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
|
97
31
|
# @option arguments [String] :q Query in the Lucene query string syntax
|
98
|
-
# @option arguments [Boolean] :request_cache Specify if request cache should be used for this request
|
99
|
-
# (defaults to index level setting)
|
100
32
|
# @option arguments [List] :routing A comma-separated list of specific routing values
|
101
|
-
# @option arguments [
|
102
|
-
#
|
103
|
-
#
|
104
|
-
|
33
|
+
# @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search
|
34
|
+
# @option arguments [String] :search_type Search operation type
|
35
|
+
# (options: query_then_fetch,dfs_query_then_fetch)
|
36
|
+
|
105
37
|
# @option arguments [Number] :size Number of hits to return (default: 10)
|
106
38
|
# @option arguments [List] :sort A comma-separated list of <field>:<direction> pairs
|
107
|
-
# @option arguments [
|
108
|
-
#
|
109
|
-
# @option arguments [
|
110
|
-
#
|
111
|
-
# @option arguments [String] :_source_exclude A list of fields to exclude from the returned _source field
|
112
|
-
# @option arguments [String] :_source_include A list of fields to extract and return from the _source field
|
113
|
-
# @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response
|
39
|
+
# @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return
|
40
|
+
# @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field
|
41
|
+
# @option arguments [List] :_source_includes A list of fields to extract and return from the _source field
|
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.
|
114
43
|
# @option arguments [List] :stats Specific 'tag' of the request for logging and statistical purposes
|
115
44
|
# @option arguments [String] :suggest_field Specify which field to use for suggestions
|
116
|
-
# @option arguments [String] :suggest_mode Specify suggest mode
|
45
|
+
# @option arguments [String] :suggest_mode Specify suggest mode
|
46
|
+
# (options: missing,popular,always)
|
47
|
+
|
117
48
|
# @option arguments [Number] :suggest_size How many suggestions to return in response
|
118
|
-
# @option arguments [
|
119
|
-
# @option arguments [Number] :terminate_after The maximum number of documents to collect for each shard
|
49
|
+
# @option arguments [String] :suggest_text The source text for which the suggestions should be returned
|
120
50
|
# @option arguments [Time] :timeout Explicit operation timeout
|
51
|
+
# @option arguments [Boolean] :track_scores Whether to calculate and return scores even if they are not used for sorting
|
52
|
+
# @option arguments [Boolean] :track_total_hits Indicate if the number of documents that match the query should be tracked
|
53
|
+
# @option arguments [Boolean] :allow_partial_search_results Indicate if an error should be returned if there is a partial search failure or timeout
|
121
54
|
# @option arguments [Boolean] :typed_keys Specify whether aggregation and suggester names should be prefixed by their respective types in the response
|
122
55
|
# @option arguments [Boolean] :version Specify whether to return document version as part of a hit
|
56
|
+
# @option arguments [Boolean] :seq_no_primary_term Specify whether to return sequence number and primary term of the last modification of each hit
|
57
|
+
# @option arguments [Boolean] :request_cache Specify if request cache should be used for this request or not, defaults to index level setting
|
123
58
|
# @option arguments [Number] :batched_reduce_size The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large.
|
124
|
-
# @option arguments [Number] :max_concurrent_shard_requests The number of concurrent shard requests this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests
|
125
|
-
# @option arguments [Number] :pre_filter_shard_size A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on it's rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.
|
59
|
+
# @option arguments [Number] :max_concurrent_shard_requests The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests
|
60
|
+
# @option arguments [Number] :pre_filter_shard_size A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on it's rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.
|
61
|
+
# @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
|
62
|
+
|
63
|
+
# @option arguments [Hash] :body The search definition using the Query DSL
|
126
64
|
#
|
127
|
-
#
|
65
|
+
# *Deprecation notice*:
|
66
|
+
# Specifying types in urls has been deprecated
|
67
|
+
# Deprecated since version 7.0.0
|
128
68
|
#
|
129
|
-
# @see https://www.elastic.co/guide/reference/api/search/
|
130
|
-
# @see https://www.elastic.co/guide/reference/api/search/request-body/
|
131
69
|
#
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
70
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-search.html
|
71
|
+
#
|
72
|
+
def search(arguments = {})
|
73
|
+
arguments = arguments.clone
|
74
|
+
arguments[:index] = UNDERSCORE_ALL if !arguments[:index] && arguments[:type]
|
138
75
|
|
139
|
-
|
76
|
+
_index = arguments.delete(:index)
|
140
77
|
|
141
|
-
|
142
|
-
params[:fielddata_fields] = Utils.__listify(params[:fielddata_fields], :escape => false) if params[:fielddata_fields]
|
78
|
+
_type = arguments.delete(:type)
|
143
79
|
|
144
|
-
|
145
|
-
|
80
|
+
method = Elasticsearch::API::HTTP_GET
|
81
|
+
path = if _index && _type
|
82
|
+
"#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_search"
|
83
|
+
elsif _index
|
84
|
+
"#{Utils.__listify(_index)}/_search"
|
85
|
+
else
|
86
|
+
"_search"
|
87
|
+
end
|
88
|
+
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
146
89
|
|
90
|
+
body = arguments[:body]
|
147
91
|
perform_request(method, path, params, body).body
|
148
92
|
end
|
149
93
|
|
150
94
|
# Register this action with its valid params when the module is loaded.
|
151
95
|
#
|
152
|
-
# @since 6.
|
96
|
+
# @since 6.2.0
|
153
97
|
ParamsRegistry.register(:search, [
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
:rest_total_hits_as_int,
|
199
|
-
:track_total_hits,
|
200
|
-
:ignore_throttled,
|
201
|
-
:seq_no_primary_term ].freeze)
|
98
|
+
:analyzer,
|
99
|
+
:analyze_wildcard,
|
100
|
+
:ccs_minimize_roundtrips,
|
101
|
+
:default_operator,
|
102
|
+
:df,
|
103
|
+
:explain,
|
104
|
+
:stored_fields,
|
105
|
+
:docvalue_fields,
|
106
|
+
:from,
|
107
|
+
:ignore_unavailable,
|
108
|
+
:ignore_throttled,
|
109
|
+
:allow_no_indices,
|
110
|
+
:expand_wildcards,
|
111
|
+
:lenient,
|
112
|
+
:preference,
|
113
|
+
:q,
|
114
|
+
:routing,
|
115
|
+
:scroll,
|
116
|
+
:search_type,
|
117
|
+
:size,
|
118
|
+
:sort,
|
119
|
+
:_source,
|
120
|
+
:_source_excludes,
|
121
|
+
:_source_includes,
|
122
|
+
:terminate_after,
|
123
|
+
:stats,
|
124
|
+
:suggest_field,
|
125
|
+
:suggest_mode,
|
126
|
+
:suggest_size,
|
127
|
+
:suggest_text,
|
128
|
+
:timeout,
|
129
|
+
:track_scores,
|
130
|
+
:track_total_hits,
|
131
|
+
:allow_partial_search_results,
|
132
|
+
:typed_keys,
|
133
|
+
:version,
|
134
|
+
:seq_no_primary_term,
|
135
|
+
:request_cache,
|
136
|
+
:batched_reduce_size,
|
137
|
+
:max_concurrent_shard_requests,
|
138
|
+
:pre_filter_shard_size,
|
139
|
+
:rest_total_hits_as_int
|
140
|
+
].freeze)
|
141
|
+
end
|
202
142
|
end
|
203
|
-
end
|
204
143
|
end
|
@@ -5,45 +5,48 @@
|
|
5
5
|
module Elasticsearch
|
6
6
|
module API
|
7
7
|
module Actions
|
8
|
-
|
9
|
-
# Returns the names of indices and shards on which a search request would be executed
|
8
|
+
# Returns information about the indices and shards that a search request would be executed against.
|
10
9
|
#
|
11
|
-
# @option arguments [
|
12
|
-
# @option arguments [String] :
|
13
|
-
# @option arguments [String] :preference Specify the node or shard the operation should be performed on
|
14
|
-
# (default: random)
|
10
|
+
# @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 [String] :preference Specify the node or shard the operation should be performed on (default: random)
|
15
12
|
# @option arguments [String] :routing Specific routing value
|
16
|
-
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
|
17
|
-
#
|
18
|
-
# @option arguments [Boolean] :
|
19
|
-
#
|
20
|
-
#
|
21
|
-
|
22
|
-
# (This includes `_all` or when no indices have been specified)
|
23
|
-
# @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices
|
24
|
-
# that are open, closed or both. (options: open, closed)
|
13
|
+
# @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false)
|
14
|
+
# @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
|
15
|
+
# @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)
|
16
|
+
# @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both.
|
17
|
+
# (options: open,closed,none,all)
|
18
|
+
|
25
19
|
#
|
26
|
-
# @see https://www.elastic.co/guide/en/elasticsearch/reference/
|
20
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-shards.html
|
27
21
|
#
|
28
|
-
def search_shards(arguments={})
|
29
|
-
|
30
|
-
|
22
|
+
def search_shards(arguments = {})
|
23
|
+
arguments = arguments.clone
|
24
|
+
|
25
|
+
_index = arguments.delete(:index)
|
26
|
+
|
27
|
+
method = Elasticsearch::API::HTTP_GET
|
28
|
+
path = if _index
|
29
|
+
"#{Utils.__listify(_index)}/_search_shards"
|
30
|
+
else
|
31
|
+
"_search_shards"
|
32
|
+
end
|
31
33
|
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
32
|
-
body = nil
|
33
34
|
|
35
|
+
body = nil
|
34
36
|
perform_request(method, path, params, body).body
|
35
37
|
end
|
36
38
|
|
37
39
|
# Register this action with its valid params when the module is loaded.
|
38
40
|
#
|
39
|
-
# @since 6.
|
41
|
+
# @since 6.2.0
|
40
42
|
ParamsRegistry.register(:search_shards, [
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
:preference,
|
44
|
+
:routing,
|
45
|
+
:local,
|
46
|
+
:ignore_unavailable,
|
47
|
+
:allow_no_indices,
|
48
|
+
:expand_wildcards
|
49
|
+
].freeze)
|
50
|
+
end
|
47
51
|
end
|
48
|
-
end
|
49
52
|
end
|