# Synonyms

class elasticsearch.client.SynonymsClient

  To use this client, access `client.synonyms` from an `Elasticsearch` client. For example:

      from elasticsearch import Elasticsearch

      # Create the client instance
      client = Elasticsearch(...)
      # Use the synonyms client
      client.synonyms.<method>(...)

  delete_synonym(*, id, error_trace=None, filter_path=None, human=None, pretty=None)

    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.

    https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation-synonyms-delete-synonym

    Parameters:

      - id (str) – The synonyms set identifier to delete.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  delete_synonym_rule(*, set_id, rule_id, error_trace=None, filter_path=None, human=None, pretty=None, refresh=None)

    Delete a synonym rule.

    Delete a synonym rule from a synonym set.

    https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation-synonyms-delete-synonym-rule

    Parameters:

      - set_id (str) – The ID of the synonym set to update.

      - rule_id (str) – The ID of the synonym rule to delete.

      - refresh (bool | None) – If true, the request will refresh the analyzers with the deleted synonym rule and wait for the new synonyms to be available before returning. If false, analyzers will not be reloaded with the deleted synonym rule

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  get_synonym(*, id, error_trace=None, filter_path=None, from_=None, human=None, pretty=None, size=None)

    Get a synonym set.

    https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation-synonyms-get-synonym

    Parameters:

      - id (str) – The synonyms set identifier to retrieve.

      - from – The starting offset for query rules to retrieve.

      - size (int | None) – The max number of query rules to retrieve.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - from_ (int | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  get_synonym_rule(*, set_id, rule_id, error_trace=None, filter_path=None, human=None, pretty=None)

    Get a synonym rule.

    Get a synonym rule from a synonym set.

    https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation-synonyms-get-synonym-rule

    Parameters:

      - set_id (str) – The ID of the synonym set to retrieve the synonym rule from.

      - rule_id (str) – The ID of the synonym rule to retrieve.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  get_synonyms_sets(*, error_trace=None, filter_path=None, from_=None, human=None, pretty=None, size=None)

    Get all synonym sets.

    Get a summary of all defined synonym sets.

    https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation-synonyms-get-synonym

    Parameters:

      - from – The starting offset for synonyms sets to retrieve.

      - size (int | None) – The maximum number of synonyms sets to retrieve.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - from_ (int | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  put_synonym(*, id, synonyms_set=None, error_trace=None, filter_path=None, human=None, pretty=None, refresh=None, body=None)

    Create or update a synonym set.

    Synonyms sets are limited to a maximum of 10,000 synonym rules per set.

    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.

    For practical examples of how to create or update a synonyms set, refer to the External documentation.

    https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation-synonyms-put-synonym

    Parameters:

      - id (str) – The ID of the synonyms set to be created or updated.

      - synonyms_set (Mapping[str, Any] | Sequence[Mapping[str, Any]] | None) – The synonym rules definitions for the synonyms set.

      - refresh (bool | None) – If true, the request will refresh the analyzers with the new synonyms set and wait for the new synonyms to be available before returning. If false, analyzers will not be reloaded with the new synonym set

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

      - body (Dict[str, Any] | None)

    Return type:

      ObjectApiResponse[Any]

  put_synonym_rule(*, set_id, rule_id, synonyms=None, error_trace=None, filter_path=None, human=None, pretty=None, refresh=None, body=None)

    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.

    https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation-synonyms-put-synonym-rule

    Parameters:

      - set_id (str) – The ID of the synonym set.

      - rule_id (str) – The ID of the synonym rule to be updated or created.

      - synonyms (str | None) – The synonym rule information definition, which must be in Solr format.

      - refresh (bool | None) – If true, the request will refresh the analyzers with the new synonym rule and wait for the new synonyms to be available before returning. If false, analyzers will not be reloaded with the new synonym rule

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

      - body (Dict[str, Any] | None)

    Return type:

      ObjectApiResponse[Any]