Module: Elasticsearch::API::Synonyms::Actions

Defined in:
lib/elasticsearch/api/actions/synonyms/get_synonym.rb,
lib/elasticsearch/api/actions/synonyms/put_synonym.rb,
lib/elasticsearch/api/actions/synonyms/delete_synonym.rb,
lib/elasticsearch/api/actions/synonyms/get_synonym_rule.rb,
lib/elasticsearch/api/actions/synonyms/put_synonym_rule.rb,
lib/elasticsearch/api/actions/synonyms/get_synonyms_sets.rb,
lib/elasticsearch/api/actions/synonyms/delete_synonym_rule.rb

Instance Method Summary collapse

Instance Method Details

#delete_synonym(arguments = {}) ⇒ Object

Delete a synonym set. You can only delete a synonyms set that is not in use by any index analyzer. Synonyms sets can be used in synonym graph token filters and synonym token filters. These synonym filters can be used as part of search analyzers. Analyzers need to be loaded when an index is restored (such as when a node starts, or the index becomes open). Even if the analyzer is not used on any field mapping, it still needs to be loaded on the index recovery phase. If any analyzers cannot be loaded, the index becomes unavailable and the cluster status becomes red or yellow as index shards are not available. To prevent that, synonyms sets that are used in analyzers can’t be deleted. A delete request in this case will return a 400 response code. To remove a synonyms set, you must first remove all indices that contain analyzers using it. You can migrate an index by creating a new index that does not contain the token filter with the synonyms set, and use the reindex API in order to copy over the index data. Once finished, you can delete the index. When the synonyms set is not used in analyzers, you will be able to delete it.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    The synonyms set identifier to delete. (Required)

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



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/synonyms/delete_synonym.rb', line 44

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 = {}) ⇒ Object

Delete a synonym rule. Delete a synonym rule from a synonym set.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :set_id (String)

    The ID of the synonym set to update. (Required)

  • :rule_id (String)

    The ID of the synonym rule to delete. (Required)

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



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
61
# File 'lib/elasticsearch/api/actions/synonyms/delete_synonym_rule.rb', line 34

def delete_synonym_rule(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'synonyms.delete_synonym_rule' }

  defined_params = [: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 = {}) ⇒ Object

Get a synonym set.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    The synonyms set identifier to retrieve. (Required)

  • :from (Integer)

    The starting offset for query rules to retrieve. Server default: 0.

  • :size (Integer)

    The max number of query rules to retrieve. Server default: 10.

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



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
# 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 = {}) ⇒ Object

Get a synonym rule. Get a synonym rule from a synonym set.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :set_id (String)

    The ID of the synonym set to retrieve the synonym rule from. (Required)

  • :rule_id (String)

    The ID of the synonym rule to retrieve. (Required)

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



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
61
# File 'lib/elasticsearch/api/actions/synonyms/get_synonym_rule.rb', line 34

def get_synonym_rule(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'synonyms.get_synonym_rule' }

  defined_params = [: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 = {}) ⇒ Object

Get all synonym sets. Get a summary of all defined synonym sets.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :from (Integer)

    The starting offset for synonyms sets to retrieve. Server default: 0.

  • :size (Integer)

    The maximum number of synonyms sets to retrieve. Server default: 10.

  • :headers (Hash)

    Custom HTTP headers

See Also:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/elasticsearch/api/actions/synonyms/get_synonyms_sets.rb', line 34

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 = {}) ⇒ Object

Create or update a synonym set. Synonyms sets are limited to a maximum of 10,000 synonym rules per set. If you need to manage more synonym rules, you can create multiple synonym sets. When an existing synonyms set is updated, the search analyzers that use the synonyms set are reloaded automatically for all indices. This is equivalent to invoking the reload search analyzers API for all indices that use the synonyms set.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :id (String)

    The ID of the synonyms set to be created or updated. (Required)

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    request body

Raises:

  • (ArgumentError)

See Also:



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/synonyms/put_synonym.rb', line 37

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 = {}) ⇒ Object

Create or update a synonym rule. Create or update a synonym rule in a synonym set. If any of the synonym rules included is invalid, the API returns an error. When you update a synonym rule, all analyzers using the synonyms set will be reloaded automatically to reflect the new rule.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :set_id (String)

    The ID of the synonym set. (Required)

  • :rule_id (String)

    The ID of the synonym rule to be updated or created. (Required)

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    request body

Raises:

  • (ArgumentError)

See Also:



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
# File 'lib/elasticsearch/api/actions/synonyms/put_synonym_rule.rb', line 37

def put_synonym_rule(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'synonyms.put_synonym_rule' }

  defined_params = [: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