Create or update a synonym set Generally available

PUT /_synonyms/{id}

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.

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

Required authorization

  • Cluster privileges: manage_search_synonyms
External documentation

Path parameters

  • id string Required

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

application/json

Body Required

  • synonyms_set object | array[object] Required

    The synonym rules definitions for the synonyms set.

    One of:
    Hide attributes Show attributes object
    • id string
    • synonyms string Required

Responses

  • 200 application/json
    Hide response attributes Show response attributes object
    • result string Required

      Values are created, updated, deleted, not_found, or noop.

    • reload_analyzers_details object
      Hide reload_analyzers_details attributes Show reload_analyzers_details attributes object
      • reload_details array[object] Required
        Hide reload_details attributes Show reload_details attributes object
        • index string Required
        • reloaded_analyzers array[string] Required
        • reloaded_node_ids array[string] Required
      • _shards object Required
        Hide _shards attributes Show _shards attributes object
        • failed number Required
        • successful number Required
        • total number Required
        • failures array[object]
          Hide failures attributes Show failures attributes object
          • index string
          • node string
          • reason object Required

            Cause and details about a request failure. This class defines the properties common to all error types. Additional details are also provided, that depend on the error type.

            Hide reason attributes Show reason attributes object
            • type string Required

              The type of error

            • reason
            • stack_trace string

              The server stack trace. Present only if the error_trace=true parameter was sent with the request.

            • caused_by object

              Cause and details about a request failure. This class defines the properties common to all error types. Additional details are also provided, that depend on the error type.

            • root_cause array[object]
            • suppressed array[object]
          • shard number Required
          • status string
        • skipped number
PUT _synonyms/my-synonyms-set 
resp = client.synonyms.put_synonym( id="my-synonyms-set", )
const response = await client.synonyms.putSynonym({ id: "my-synonyms-set", });
response = client.synonyms.put_synonym( id: "my-synonyms-set" )
$resp = $client->synonyms()->putSynonym([ "id" => "my-synonyms-set", ]);
curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_synonyms/my-synonyms-set"