Create or update a synonym set Generally available; Added in 8.10.0

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.

Required authorization

  • Cluster privileges: manage_search_synonyms

Path parameters

  • id string Required

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

Query parameters

  • refresh boolean

    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

application/json

Body Required

Responses

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

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

    • 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
      • _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

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

            • 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"