Module: Elasticsearch::API::Actions
- Defined in:
- lib/elasticsearch/api/actions/get.rb,
lib/elasticsearch/api/actions/bulk.rb,
lib/elasticsearch/api/actions/info.rb,
lib/elasticsearch/api/actions/mget.rb,
lib/elasticsearch/api/actions/ping.rb,
lib/elasticsearch/api/actions/count.rb,
lib/elasticsearch/api/actions/index.rb,
lib/elasticsearch/api/actions/create.rb,
lib/elasticsearch/api/actions/delete.rb,
lib/elasticsearch/api/actions/exists.rb,
lib/elasticsearch/api/actions/scroll.rb,
lib/elasticsearch/api/actions/search.rb,
lib/elasticsearch/api/actions/update.rb,
lib/elasticsearch/api/actions/explain.rb,
lib/elasticsearch/api/actions/msearch.rb,
lib/elasticsearch/api/actions/reindex.rb,
lib/elasticsearch/api/actions/rank_eval.rb,
lib/elasticsearch/api/actions/field_caps.rb,
lib/elasticsearch/api/actions/get_script.rb,
lib/elasticsearch/api/actions/get_source.rb,
lib/elasticsearch/api/actions/knn_search.rb,
lib/elasticsearch/api/actions/put_script.rb,
lib/elasticsearch/api/actions/search_mvt.rb,
lib/elasticsearch/api/actions/terms_enum.rb,
lib/elasticsearch/api/actions/termvectors.rb,
lib/elasticsearch/api/actions/capabilities.rb,
lib/elasticsearch/api/actions/clear_scroll.rb,
lib/elasticsearch/api/actions/mtermvectors.rb,
lib/elasticsearch/api/actions/delete_script.rb,
lib/elasticsearch/api/actions/exists_source.rb,
lib/elasticsearch/api/actions/health_report.rb,
lib/elasticsearch/api/actions/search_shards.rb,
lib/elasticsearch/api/actions/delete_by_query.rb,
lib/elasticsearch/api/actions/search_template.rb,
lib/elasticsearch/api/actions/update_by_query.rb,
lib/elasticsearch/api/actions/msearch_template.rb,
lib/elasticsearch/api/actions/get_script_context.rb,
lib/elasticsearch/api/actions/open_point_in_time.rb,
lib/elasticsearch/api/actions/reindex_rethrottle.rb,
lib/elasticsearch/api/actions/close_point_in_time.rb,
lib/elasticsearch/api/actions/get_script_languages.rb,
lib/elasticsearch/api/actions/render_search_template.rb,
lib/elasticsearch/api/actions/scripts_painless_execute.rb,
lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb,
lib/elasticsearch/api/actions/update_by_query_rethrottle.rb
Instance Method Summary collapse
-
#bulk(arguments = {}) ⇒ Object
Bulk index or delete documents.
-
#capabilities(arguments = {}) ⇒ Object
Checks if the specified combination of method, API, parameters, and arbitrary capabilities are supported This functionality is Experimental and may be changed or removed completely in a future release.
-
#clear_scroll(arguments = {}) ⇒ Object
Clear a scrolling search.
-
#close_point_in_time(arguments = {}) ⇒ Object
Close a point in time.
-
#count(arguments = {}) ⇒ Object
Count search results.
-
#create(arguments = {}) ⇒ Object
Create a new document in the index.
-
#delete(arguments = {}) ⇒ Object
Delete a document.
-
#delete_by_query(arguments = {}) ⇒ Object
Delete documents.
-
#delete_by_query_rethrottle(arguments = {}) ⇒ Object
Throttle a delete by query operation.
-
#delete_script(arguments = {}) ⇒ Object
Delete a script or search template.
-
#exists(arguments = {}) ⇒ Object
(also: #exists?)
Check a document.
-
#exists_source(arguments = {}) ⇒ Object
(also: #exists_source?)
Check for a document source.
-
#explain(arguments = {}) ⇒ Object
Explain a document match result.
-
#field_caps(arguments = {}) ⇒ Object
Get the field capabilities.
-
#get(arguments = {}) ⇒ Object
Get a document by its ID.
-
#get_script(arguments = {}) ⇒ Object
Get a script or search template.
-
#get_script_context(arguments = {}) ⇒ Object
Get script contexts.
-
#get_script_languages(arguments = {}) ⇒ Object
Get script languages.
-
#get_source(arguments = {}) ⇒ Object
Get a document’s source.
-
#health_report(arguments = {}) ⇒ Object
Get the cluster health.
-
#index(arguments = {}) ⇒ Object
Create or update a document in an index.
-
#info(arguments = {}) ⇒ Object
Get cluster info.
-
#knn_search(arguments = {}) ⇒ Object
Run a knn search This functionality is Experimental and may be changed or removed completely in a future release.
-
#mget(arguments = {}) ⇒ Object
Get multiple documents.
-
#msearch(arguments = {}) ⇒ Object
Run multiple searches.
-
#msearch_template(arguments = {}) ⇒ Object
Run multiple templated searches.
-
#mtermvectors(arguments = {}) ⇒ Object
Get multiple term vectors.
-
#open_point_in_time(arguments = {}) ⇒ Object
Open a point in time.
-
#ping(arguments = {}) ⇒ Object
Ping the cluster.
-
#put_script(arguments = {}) ⇒ Object
Create or update a script or search template.
-
#rank_eval(arguments = {}) ⇒ Object
Evaluate ranked search results.
-
#reindex(arguments = {}) ⇒ Object
Reindex documents.
-
#reindex_rethrottle(arguments = {}) ⇒ Object
Throttle a reindex operation.
-
#render_search_template(arguments = {}) ⇒ Object
Render a search template.
-
#scripts_painless_execute(arguments = {}) ⇒ Object
Run a script This functionality is Experimental and may be changed or removed completely in a future release.
-
#scroll(arguments = {}) ⇒ Object
Run a scrolling search.
-
#search(arguments = {}) ⇒ Object
Run a search.
-
#search_mvt(arguments = {}) ⇒ Object
Search a vector tile.
-
#search_shards(arguments = {}) ⇒ Object
Get the search shards.
-
#search_template(arguments = {}) ⇒ Object
Run a search with a search template.
-
#terms_enum(arguments = {}) ⇒ Object
Get terms in an index.
-
#termvector(arguments = {}) ⇒ Object
Deprecated: Use the plural version, #termvectors.
-
#termvectors(arguments = {}) ⇒ Object
Get term vector information.
-
#update(arguments = {}) ⇒ Object
Update a document.
-
#update_by_query(arguments = {}) ⇒ Object
Update documents.
-
#update_by_query_rethrottle(arguments = {}) ⇒ Object
Throttle an update by query operation.
Instance Method Details
#bulk(arguments = {}) ⇒ Object
Bulk index or delete documents
or the conveniency “combined” format can be passed, refer to Elasticsearch::API::Utils.__bulkify documentation.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/elasticsearch/api/actions/bulk.rb', line 45 def bulk(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'bulk' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index "#{Utils.__listify(_index)}/_bulk" else '_bulk' end params = Utils.process_params(arguments) payload = if body.is_a? Array Elasticsearch::API::Utils.__bulkify(body) else body end headers.merge!('Content-Type' => 'application/x-ndjson') Elasticsearch::API::Response.new( perform_request(method, path, params, payload, headers, request_opts) ) end |
#capabilities(arguments = {}) ⇒ Object
Checks if the specified combination of method, API, parameters, and arbitrary capabilities are supported This functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/elasticsearch/api/actions/capabilities.rb', line 39 def capabilities(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'capabilities' } arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil method = Elasticsearch::API::HTTP_GET path = '_capabilities' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#clear_scroll(arguments = {}) ⇒ Object
Clear a scrolling search
*Deprecation notice*: A scroll id can be quite large and should be specified as part of the body Deprecated since version 7.0.0
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/elasticsearch/api/actions/clear_scroll.rb', line 37 def clear_scroll(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'clear_scroll' } defined_params = [:scroll_id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _scroll_id = arguments.delete(:scroll_id) method = Elasticsearch::API::HTTP_DELETE path = if _scroll_id "_search/scroll/#{Utils.__listify(_scroll_id)}" else '_search/scroll' end params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) Utils.__rescue_from_not_found do Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end else Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end end |
#close_point_in_time(arguments = {}) ⇒ Object
Close a point in time
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/elasticsearch/api/actions/close_point_in_time.rb', line 31 def close_point_in_time(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'close_point_in_time' } raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) method = Elasticsearch::API::HTTP_DELETE path = '_pit' params = {} Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#count(arguments = {}) ⇒ Object
Count search results
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/elasticsearch/api/actions/count.rb', line 46 def count(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'count' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = if body Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end path = if _index "#{Utils.__listify(_index)}/_count" else '_count' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#create(arguments = {}) ⇒ Object
Create a new document in the index
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/elasticsearch/api/actions/create.rb', line 43 def create(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'create' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? if arguments[:id] index arguments.update op_type: 'create' else index arguments end end |
#delete(arguments = {}) ⇒ Object
Delete a document
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/elasticsearch/api/actions/delete.rb', line 40 def delete(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'delete' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _id = arguments.delete(:id) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_DELETE path = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}" params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) Utils.__rescue_from_not_found do Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end else Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end end |
#delete_by_query(arguments = {}) ⇒ Object
Delete documents
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/elasticsearch/api/actions/delete_by_query.rb', line 61 def delete_by_query(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'delete_by_query' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = "#{Utils.__listify(_index)}/_delete_by_query" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#delete_by_query_rethrottle(arguments = {}) ⇒ Object
Throttle a delete by query operation
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb', line 32 def delete_by_query_rethrottle(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'delete_by_query_rethrottle' } defined_params = [:task_id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _task_id = arguments.delete(:task_id) method = Elasticsearch::API::HTTP_POST path = "_delete_by_query/#{Utils.__listify(_task_id)}/_rethrottle" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#delete_script(arguments = {}) ⇒ Object
Delete a script or search template
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/elasticsearch/api/actions/delete_script.rb', line 33 def delete_script(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'delete_script' } defined_params = [:id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_DELETE path = "_scripts/#{Utils.__listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#exists(arguments = {}) ⇒ Object Also known as: exists?
Check a document
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/elasticsearch/api/actions/exists.rb', line 42 def exists(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'exists' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _id = arguments.delete(:id) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_HEAD path = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}" params = Utils.process_params(arguments) Utils.__rescue_from_not_found do perform_request(method, path, params, body, headers, request_opts).status == 200 end end |
#exists_source(arguments = {}) ⇒ Object Also known as: exists_source?
Check for a document source
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/elasticsearch/api/actions/exists_source.rb', line 41 def exists_source(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'exists_source' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _id = arguments.delete(:id) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_HEAD path = "#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#explain(arguments = {}) ⇒ Object
Explain a document match result
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/elasticsearch/api/actions/explain.rb', line 45 def explain(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'explain' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _id = arguments.delete(:id) _index = arguments.delete(:index) method = if body Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end path = "#{Utils.__listify(_index)}/_explain/#{Utils.__listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#field_caps(arguments = {}) ⇒ Object
Get the field capabilities
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/elasticsearch/api/actions/field_caps.rb', line 40 def field_caps(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'field_caps' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = if body Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end path = if _index "#{Utils.__listify(_index)}/_field_caps" else '_field_caps' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#get(arguments = {}) ⇒ Object
Get a document by its ID
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/elasticsearch/api/actions/get.rb', line 43 def get(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'get' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _id = arguments.delete(:id) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}" params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) Utils.__rescue_from_not_found do Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end else Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end end |
#get_script(arguments = {}) ⇒ Object
Get a script or search template
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/elasticsearch/api/actions/get_script.rb', line 32 def get_script(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'get_script' } defined_params = [:id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_GET path = "_scripts/#{Utils.__listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#get_script_context(arguments = {}) ⇒ Object
Get script contexts
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/elasticsearch/api/actions/get_script_context.rb', line 30 def get_script_context(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'get_script_context' } arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil method = Elasticsearch::API::HTTP_GET path = '_script_context' params = {} Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#get_script_languages(arguments = {}) ⇒ Object
Get script languages
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/elasticsearch/api/actions/get_script_languages.rb', line 30 def get_script_languages(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'get_script_languages' } arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil method = Elasticsearch::API::HTTP_GET path = '_script_language' params = {} Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#get_source(arguments = {}) ⇒ Object
Get a document’s source
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/elasticsearch/api/actions/get_source.rb', line 41 def get_source(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'get_source' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _id = arguments.delete(:id) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = "#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#health_report(arguments = {}) ⇒ Object
Get the cluster health
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/elasticsearch/api/actions/health_report.rb', line 34 def health_report(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'health_report' } defined_params = [:feature].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _feature = arguments.delete(:feature) method = Elasticsearch::API::HTTP_GET path = if _feature "_health_report/#{Utils.__listify(_feature)}" else '_health_report' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#index(arguments = {}) ⇒ Object
Create or update a document in an index
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/elasticsearch/api/actions/index.rb', line 46 def index(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'index' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _id = arguments.delete(:id) _index = arguments.delete(:index) method = _id ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST path = if _index && _id "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}" else "#{Utils.__listify(_index)}/_doc" end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#info(arguments = {}) ⇒ Object
Get cluster info
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/elasticsearch/api/actions/info.rb', line 30 def info(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'info' } arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil method = Elasticsearch::API::HTTP_GET path = '' params = {} Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#knn_search(arguments = {}) ⇒ Object
Run a knn search This functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/elasticsearch/api/actions/knn_search.rb', line 37 def knn_search(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'knn_search' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = "#{Utils.__listify(_index)}/_knn_search" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#mget(arguments = {}) ⇒ Object
Get multiple documents
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/elasticsearch/api/actions/mget.rb', line 41 def mget(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'mget' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index "#{Utils.__listify(_index)}/_mget" else '_mget' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#msearch(arguments = {}) ⇒ Object
Run multiple searches
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/elasticsearch/api/actions/msearch.rb', line 45 def msearch(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'msearch' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index "#{Utils.__listify(_index)}/_msearch" else '_msearch' end params = Utils.process_params(arguments) if body.is_a?(Array) && body.any? { |d| d.has_key? :search } payload = body.each_with_object([]) do |item, sum| = item data = .delete(:search) sum << sum << data end.map { |item| Elasticsearch::API.serializer.dump(item) } payload << '' unless payload.empty? payload = payload.join("\n") elsif body.is_a?(Array) payload = body.map { |d| d.is_a?(String) ? d : Elasticsearch::API.serializer.dump(d) } payload << '' unless payload.empty? payload = payload.join("\n") else payload = body end headers.merge!('Content-Type' => 'application/x-ndjson') Elasticsearch::API::Response.new( perform_request(method, path, params, payload, headers, request_opts) ) end |
#msearch_template(arguments = {}) ⇒ Object
Run multiple templated searches
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/elasticsearch/api/actions/msearch_template.rb', line 37 def msearch_template(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'msearch_template' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index "#{Utils.__listify(_index)}/_msearch/template" else '_msearch/template' end params = Utils.process_params(arguments) if body.is_a?(Array) payload = body.map { |d| d.is_a?(String) ? d : Elasticsearch::API.serializer.dump(d) } payload << '' unless payload.empty? payload = payload.join("\n") else payload = body end headers.merge!('Content-Type' => 'application/x-ndjson') Elasticsearch::API::Response.new( perform_request(method, path, params, payload, headers, request_opts) ) end |
#mtermvectors(arguments = {}) ⇒ Object
Get multiple term vectors
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/elasticsearch/api/actions/mtermvectors.rb', line 44 def mtermvectors(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'mtermvectors' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = if (ids = arguments.delete(:ids)) { ids: ids } else arguments.delete(:body) end _index = arguments.delete(:index) method = if body Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end path = if _index "#{Utils.__listify(_index)}/_mtermvectors" else '_mtermvectors' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#open_point_in_time(arguments = {}) ⇒ Object
Open a point in time
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/elasticsearch/api/actions/open_point_in_time.rb', line 39 def open_point_in_time(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'open_point_in_time' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = "#{Utils.__listify(_index)}/_pit" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#ping(arguments = {}) ⇒ Object
Ping the cluster
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/elasticsearch/api/actions/ping.rb', line 30 def ping(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'ping' } arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil method = Elasticsearch::API::HTTP_HEAD path = '' params = {} begin perform_request(method, path, params, body, headers, request_opts).status == 200 rescue Exception => e raise e unless e.class.to_s =~ /NotFound|ConnectionFailed/ || e. =~ /Not *Found|404|ConnectionFailed/i false end end |
#put_script(arguments = {}) ⇒ Object
Create or update a script or search template
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/elasticsearch/api/actions/put_script.rb', line 35 def put_script(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'put_script' } defined_params = %i[id context].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _id = arguments.delete(:id) _context = arguments.delete(:context) method = Elasticsearch::API::HTTP_PUT path = if _id && _context "_scripts/#{Utils.__listify(_id)}/#{Utils.__listify(_context)}" else "_scripts/#{Utils.__listify(_id)}" end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#rank_eval(arguments = {}) ⇒ Object
Evaluate ranked search results
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/elasticsearch/api/actions/rank_eval.rb', line 36 def rank_eval(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'rank_eval' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index "#{Utils.__listify(_index)}/_rank_eval" else '_rank_eval' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#reindex(arguments = {}) ⇒ Object
Reindex documents
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/elasticsearch/api/actions/reindex.rb', line 40 def reindex(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'reindex' } raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST path = '_reindex' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#reindex_rethrottle(arguments = {}) ⇒ Object
Throttle a reindex operation
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/elasticsearch/api/actions/reindex_rethrottle.rb', line 32 def reindex_rethrottle(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'reindex_rethrottle' } defined_params = [:task_id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _task_id = arguments.delete(:task_id) method = Elasticsearch::API::HTTP_POST path = "_reindex/#{Utils.__listify(_task_id)}/_rethrottle" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#render_search_template(arguments = {}) ⇒ Object
Render a search template
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/elasticsearch/api/actions/render_search_template.rb', line 32 def render_search_template(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'render_search_template' } defined_params = [:id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_POST path = if _id "_render/template/#{Utils.__listify(_id)}" else '_render/template' end params = {} Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#scripts_painless_execute(arguments = {}) ⇒ Object
Run a script This functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/elasticsearch/api/actions/scripts_painless_execute.rb', line 35 def scripts_painless_execute(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'scripts_painless_execute' } raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST path = '_scripts/painless/_execute' params = {} Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#scroll(arguments = {}) ⇒ Object
Run a scrolling search
*Deprecation notice*: A scroll id can be quite large and should be specified as part of the body Deprecated since version 7.0.0
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/elasticsearch/api/actions/scroll.rb', line 39 def scroll(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'scroll' } defined_params = [:scroll_id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _scroll_id = arguments.delete(:scroll_id) method = if body Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end path = if _scroll_id "_search/scroll/#{Utils.__listify(_scroll_id)}" else '_search/scroll' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#search(arguments = {}) ⇒ Object
Run a search
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/elasticsearch/api/actions/search.rb', line 77 def search(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'search' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = if body Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end path = if _index "#{Utils.__listify(_index)}/_search" else '_search' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#search_mvt(arguments = {}) ⇒ Object
Search a vector tile
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/elasticsearch/api/actions/search_mvt.rb', line 44 def search_mvt(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'search_mvt' } defined_params = %i[index field zoom x y].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'field' missing" unless arguments[:field] raise ArgumentError, "Required argument 'zoom' missing" unless arguments[:zoom] raise ArgumentError, "Required argument 'x' missing" unless arguments[:x] raise ArgumentError, "Required argument 'y' missing" unless arguments[:y] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) _field = arguments.delete(:field) _zoom = arguments.delete(:zoom) _x = arguments.delete(:x) _y = arguments.delete(:y) method = Elasticsearch::API::HTTP_POST path = "#{Utils.__listify(_index)}/_mvt/#{Utils.__listify(_field)}/#{Utils.__listify(_zoom)}/#{Utils.__listify(_x)}/#{Utils.__listify(_y)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#search_shards(arguments = {}) ⇒ Object
Get the search shards
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/elasticsearch/api/actions/search_shards.rb', line 38 def search_shards(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'search_shards' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = if _index "#{Utils.__listify(_index)}/_search_shards" else '_search_shards' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#search_template(arguments = {}) ⇒ Object
Run a search with a search template
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/elasticsearch/api/actions/search_template.rb', line 45 def search_template(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'search_template' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index "#{Utils.__listify(_index)}/_search/template" else '_search/template' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#terms_enum(arguments = {}) ⇒ Object
Get terms in an index
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/elasticsearch/api/actions/terms_enum.rb', line 32 def terms_enum(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'terms_enum' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = "#{Utils.__listify(_index)}/_terms_enum" params = {} Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#termvector(arguments = {}) ⇒ Object
Deprecated: Use the plural version, #termvectors
84 85 86 87 |
# File 'lib/elasticsearch/api/actions/termvectors.rb', line 84 def termvector(arguments = {}) warn '[DEPRECATION] `termvector` is deprecated. Please use the plural version, `termvectors` instead.' termvectors(arguments.merge(endpoint: '_termvector')) end |
#termvectors(arguments = {}) ⇒ Object
Get term vector information
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/elasticsearch/api/actions/termvectors.rb', line 44 def termvectors(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'termvectors' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) _id = arguments.delete(:id) method = if body Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end arguments.delete(:endpoint) path = if _index && _id "#{Utils.__listify(_index)}/_termvectors/#{Utils.__listify(_id)}" else "#{Utils.__listify(_index)}/_termvectors" end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#update(arguments = {}) ⇒ Object
Update a document
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/elasticsearch/api/actions/update.rb', line 46 def update(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'update' } defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _id = arguments.delete(:id) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = "#{Utils.__listify(_index)}/_update/#{Utils.__listify(_id)}" params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) Utils.__rescue_from_not_found do Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end else Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end end |
#update_by_query(arguments = {}) ⇒ Object
Update documents
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/elasticsearch/api/actions/update_by_query.rb', line 63 def update_by_query(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'update_by_query' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = "#{Utils.__listify(_index)}/_update_by_query" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#update_by_query_rethrottle(arguments = {}) ⇒ Object
Throttle an update by query operation
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/elasticsearch/api/actions/update_by_query_rethrottle.rb', line 32 def update_by_query_rethrottle(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'update_by_query_rethrottle' } defined_params = [:task_id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _task_id = arguments.delete(:task_id) method = Elasticsearch::API::HTTP_POST path = "_update_by_query/#{Utils.__listify(_task_id)}/_rethrottle" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |