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. ##Required authorization
- Cluster privileges:
manage_search_synonyms
Query parameters
-
If
true, the request will refresh the analyzers with the new synonym rule and wait for the new synonyms to be available before returning. Iffalse, analyzers will not be reloaded with the new synonym rule
PUT
/_synonyms/{set_id}/{rule_id}
Console
PUT _synonyms/my-synonyms-set/test-1
{
"synonyms": "hello, hi, howdy"
}
curl \
--request PUT 'http://api.example.com/_synonyms/{set_id}/{rule_id}' \
--header "Content-Type: application/json" \
--data '"{\n \"synonyms\": \"hello, hi, howdy\"\n}"'
Request examples
synonyms/apis/put-synonym-rule.asciidoc:107
{
"synonyms": "hello, hi, howdy"
}
An example body for a `PUT _synonyms/my-synonyms-set/test-1` request.
{
"synonyms": "hello, hi, howdy"
}
Response examples (200)
A successful response from `PUT _synonyms/my-synonyms-set/test-1`.
{
"result": "updated",
"reload_analyzers_details": {
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"reload_details": [
{
"index": "test-index",
"reloaded_analyzers": [
"my_search_analyzer"
],
"reloaded_node_ids": [
"1wYFZzq8Sxeu_Jvt9mlbkg"
]
}
]
}
}