Create or update a synonym rule Added in 8.10.0

PUT /_synonyms/{set_id}/{rule_id}

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.

Path parameters

  • set_id string Required

    The ID of the synonym set.

  • rule_id string Required

    The ID of the synonym rule to be updated or created.

application/json

Body Required

Responses

PUT /_synonyms/{set_id}/{rule_id}
curl \
 --request PUT 'http://api.example.com/_synonyms/{set_id}/{rule_id}' \
 --header "Authorization: $API_KEY" \
 --header "Content-Type: application/json" \
 --data '"{\n  \"synonyms\": \"hello, hi, howdy\"\n}"'
Request example
{
  "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"
        ]
      }
    ]
  }
}