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.

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.

Query parameters

  • refresh boolean Generally available; Added in 9.1.0

    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

  • synonyms_set object | array[object] Required

    The synonym rules definitions for the synonyms set.

    One of:
    Hide attributes Show attributes object
    • id string

      The identifier for the synonym rule. If you do not specify a synonym rule ID when you create a rule, an identifier is created automatically by Elasticsearch.

    • synonyms string Required

      The synonyms that conform the synonym rule in Solr format.

Responses

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

      The update operation result.

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

    • reload_analyzers_details object

      Updating a synonyms set can reload the associated analyzers in case refresh is set to true. This information is the analyzers reloading result.

      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

          The number of shards the operation or search attempted to run on but failed.

        • successful number Required

          The number of shards the operation or search succeeded on.

        • total number Required

          The number of shards the operation or search will run on overall.

        • failures array[object]
        • skipped number
PUT /_synonyms/{id}
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"