Method: ElasticsearchServerless::API::Actions#count
- Defined in:
- lib/elasticsearch-serverless/api/count.rb
#count(arguments = {}) ⇒ Object
Returns number of documents matching a query.
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 |
# File 'lib/elasticsearch-serverless/api/count.rb', line 58 def count(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || "count" } defined_params = [:index].inject({}) do |set_variables, variable| set_variables[variable] = arguments[variable] if arguments.key?(variable) set_variables 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 ElasticsearchServerless::API::HTTP_POST else ElasticsearchServerless::API::HTTP_GET end path = if _index "#{Utils.listify(_index)}/_count" else "_count" end params = Utils.process_params(arguments) ElasticsearchServerless::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |