lib/elasticsearch/api/actions/termvectors.rb in elasticsearch-api-8.12.2 vs lib/elasticsearch/api/actions/termvectors.rb in elasticsearch-api-8.13.0

- old
+ new

@@ -37,27 +37,26 @@ # @option arguments [Number] :version Explicit version number for concurrency control # @option arguments [String] :version_type Specific version type (options: internal, external, external_gte) # @option arguments [Hash] :headers Custom HTTP headers # @option arguments [Hash] :body Define parameters and or supply a document to get termvectors for. See documentation. # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-termvectors.html + # @see https://www.elastic.co/guide/en/elasticsearch/reference/8.13/docs-termvectors.html # def termvectors(arguments = {}) - request_opts = { endpoint: arguments[:endpoint] || "termvectors" } + request_opts = { endpoint: arguments[:endpoint] || 'termvectors' } - defined_params = [:index, :id].inject({}) do |set_variables, variable| + defined_params = %i[index id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) - set_variables 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) + body = arguments.delete(:body) _index = arguments.delete(:index) _id = arguments.delete(:id) @@ -65,26 +64,27 @@ Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end - endpoint = arguments.delete(:endpoint) || '_termvectors' - path = if _index && _id - "#{Utils.__listify(_index)}/_termvectors/#{Utils.__listify(_id)}" - else - "#{Utils.__listify(_index)}/_termvectors" - 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 # Deprecated: Use the plural version, {#termvectors} # def termvector(arguments = {}) - termvectors(arguments.merge endpoint: '_termvector') + warn '[DEPRECATION] `termvector` is deprecated. Please use the plural version, `termvectors` instead.' + termvectors(arguments.merge(endpoint: '_termvector')) end end end end