Create or update a synonym set

  • PUT /_synonyms/{id}
Auth

Synonym sets are limited to a maximum of 100,000 synonym rules per set by default. This limit is configurable using the synonyms.max_synonym_rules cluster setting.

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.

About synonym API examples

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

append boolean · default: false

If true, the provided synonym rules are appended to the existing set, with matching IDs overwriting existing rules. If false, the entire synonyms set is replaced with the new synonym rules definitions.

Request body

synonyms_set union oneOf required

The synonym rules definitions for the synonyms set.

object or 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

application/json
result enum required

The update operation result.

Values: created updated deleted not_found 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.

reload_details object[] required
index string required
reloaded_analyzers string[] required
reloaded_node_ids string[] required
_shards object required
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 object[]
index string
node string
reason object required
type string required

The type of error

reason union string nullable

A human-readable explanation of the error, in English.

One of: string
stack_trace string

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

caused_by object
Same fields as reason in failures
root_cause object[]
Same fields as reason in failures
suppressed object[]
Same fields as reason in failures
shard number
status string
primary boolean
skipped number

The synonym rules are not valid.

application/json
error object required
type string required

The type of error

reason union string nullable

A human-readable explanation of the error, in English.

One of: string
stack_trace string

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

caused_by object
Same fields as error
root_cause object[]
Same fields as error
suppressed object[]
Same fields as error
status number required