module Elasticsearch::API::Synonyms::Actions

Public Instance Methods

delete_synonym(arguments = {}) click to toggle source

Deletes a synonym set

@option arguments [String] :id The id of the synonyms set to be deleted @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/delete-synonyms-set.html

# File lib/elasticsearch/api/actions/synonyms/delete_synonym.rb, line 32
def delete_synonym(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'synonyms.delete_synonym' }

  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   = "_synonyms/#{Utils.__listify(_id)}"
  params = {}

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end
delete_synonym_rule(arguments = {}) click to toggle source

Deletes a synonym rule in a synonym set

@option arguments [String] :set_id The id of the synonym set to be updated @option arguments [String] :rule_id The id of the synonym rule to be deleted @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/delete-synonym-rule.html

# File lib/elasticsearch/api/actions/synonyms/delete_synonym_rule.rb, line 33
def delete_synonym_rule(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'synonyms.delete_synonym_rule' }

  defined_params = %i[set_id rule_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 'set_id' missing" unless arguments[:set_id]
  raise ArgumentError, "Required argument 'rule_id' missing" unless arguments[:rule_id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _set_id = arguments.delete(:set_id)

  _rule_id = arguments.delete(:rule_id)

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_synonyms/#{Utils.__listify(_set_id)}/#{Utils.__listify(_rule_id)}"
  params = {}

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end
get_synonym(arguments = {}) click to toggle source

Retrieves a synonym set

@option arguments [String] :id The name of the synonyms set to be retrieved @option arguments [Integer] :from Starting offset @option arguments [Integer] :size specifies a max number of results to get @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/get-synonyms-set.html

# File lib/elasticsearch/api/actions/synonyms/get_synonym.rb, line 34
def get_synonym(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'synonyms.get_synonym' }

  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   = "_synonyms/#{Utils.__listify(_id)}"
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end
get_synonym_rule(arguments = {}) click to toggle source

Retrieves a synonym rule from a synonym set

@option arguments [String] :set_id The id of the synonym set to retrieve the synonym rule from @option arguments [String] :rule_id The id of the synonym rule to retrieve @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/get-synonym-rule.html

# File lib/elasticsearch/api/actions/synonyms/get_synonym_rule.rb, line 33
def get_synonym_rule(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'synonyms.get_synonym_rule' }

  defined_params = %i[set_id rule_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 'set_id' missing" unless arguments[:set_id]
  raise ArgumentError, "Required argument 'rule_id' missing" unless arguments[:rule_id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _set_id = arguments.delete(:set_id)

  _rule_id = arguments.delete(:rule_id)

  method = Elasticsearch::API::HTTP_GET
  path   = "_synonyms/#{Utils.__listify(_set_id)}/#{Utils.__listify(_rule_id)}"
  params = {}

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end
get_synonyms_sets(arguments = {}) click to toggle source

Retrieves a summary of all defined synonym sets

@option arguments [Integer] :from Starting offset @option arguments [Integer] :size specifies a max number of results to get @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/list-synonyms-sets.html

# File lib/elasticsearch/api/actions/synonyms/get_synonyms_sets.rb, line 33
def get_synonyms_sets(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'synonyms.get_synonyms_sets' }

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body   = nil

  method = Elasticsearch::API::HTTP_GET
  path   = '_synonyms'
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end
put_synonym(arguments = {}) click to toggle source

Creates or updates a synonyms set

@option arguments [String] :id The id of the synonyms set to be created or updated @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body Synonyms set rules (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/put-synonyms-set.html

# File lib/elasticsearch/api/actions/synonyms/put_synonym.rb, line 33
def put_synonym(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'synonyms.put_synonym' }

  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]
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = arguments.delete(:body)

  _id = arguments.delete(:id)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_synonyms/#{Utils.__listify(_id)}"
  params = {}

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end
put_synonym_rule(arguments = {}) click to toggle source

Creates or updates a synonym rule in a synonym set

@option arguments [String] :set_id The id of the synonym set to be updated with the synonym rule @option arguments [String] :rule_id The id of the synonym rule to be updated or created @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body Synonym rule (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/put-synonym-rule.html

# File lib/elasticsearch/api/actions/synonyms/put_synonym_rule.rb, line 34
def put_synonym_rule(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'synonyms.put_synonym_rule' }

  defined_params = %i[set_id rule_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 'set_id' missing" unless arguments[:set_id]
  raise ArgumentError, "Required argument 'rule_id' missing" unless arguments[:rule_id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = arguments.delete(:body)

  _set_id = arguments.delete(:set_id)

  _rule_id = arguments.delete(:rule_id)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_synonyms/#{Utils.__listify(_set_id)}/#{Utils.__listify(_rule_id)}"
  params = {}

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end