---
type: api
title: Delete a synonym rule
description: Delete a synonym rule from a synonym set.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-synonyms-delete-synonym-rule
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-synonyms-delete-synonym-rule
products:
  - Elasticsearch Serverless
---

# Delete a synonym rule

Availability:

## Paths

- `DELETE` `/_synonyms/{set_id}/{rule_id}`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/authentication#apikeyauth)

#### Path Parameters

- `set_id` (string Id)
  The ID of the synonym set to update.
- `rule_id` (string Id)
  The ID of the synonym rule to delete.

## Description

Delete a synonym rule from a synonym set.

## Required authorization

* Cluster privileges: `manage_search_synonyms`

## Response

`application/json`

- `result` (enum Result)
  The update operation result.
  Values: `created`, `updated`, `deleted`, `not_found`, `noop`
- `reload_analyzers_details` ({} ReloadResult)
  Updating synonyms in a synonym set can reload the associated analyzers in case refresh is set to true.
This information is the analyzers reloading result.
  - `reload_details` ([] ReloadDetails)
    - `index` (string)
    - `reloaded_analyzers` ([] string)
    - `reloaded_node_ids` ([] string)
  - `_shards` ({} ShardStatistics)
    - `failed` (number uint)
      The number of shards the operation or search attempted to run on but failed.
    - `successful` (number uint)
      The number of shards the operation or search succeeded on.
    - `total` (number uint)
      The number of shards the operation or search will run on overall.
    - `failures` ([] ShardFailure)
      - `index` (string IndexName)
      - `node` (string)
      - `reason` ({} ErrorCause)
        - `type` (string)
          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` ({} ErrorCause) — recursive
          Same fields as `reason` in `failures`
        - `root_cause` ([] ErrorCause) — recursive
          Same fields as `reason` in `failures`
        - `suppressed` ([] ErrorCause) — recursive
          Same fields as `reason` in `failures`
      - `shard` (number)
      - `status` (string)
      - `primary` (boolean)
    - `skipped` (number uint)
## Code Examples

#### Console

```console
DELETE _synonyms/my-synonyms-set/test-1
```

#### JavaScript

```javascript
const response = await client.synonyms.deleteSynonymRule({
  set_id: "my-synonyms-set",
  rule_id: "test-1",
});
```

#### Python

```python
resp = client.synonyms.delete_synonym_rule(
    set_id="my-synonyms-set",
    rule_id="test-1",
)
```

#### curl

```curl
curl -X DELETE "$ELASTICSEARCH_URL/_synonyms/my-synonyms-set/test-1" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.synonyms().deleteSynonymRule(d -> d
    .ruleId("test-1")
    .setId("my-synonyms-set")
);
```

#### C#

```c#
var response = await client.Synonyms.DeleteSynonymRuleAsync(setId: "my-synonyms-set", ruleId: "test-1");
```

#### PHP

```php
$resp = $client->synonyms()->deleteSynonymRule([
    "set_id" => "my-synonyms-set",
    "rule_id" => "test-1",
]);
```

#### Ruby

```ruby
response = client.synonyms.delete_synonym_rule(
  set_id: "my-synonyms-set",
  rule_id: "test-1"
)
```

## Response Examples

#### Synonym rule delete response example1

A successful response from `DELETE _synonyms/my-synonyms-set/test-1`. All analyzers using this synonyms set will be reloaded automatically to reflect the rule being deleted.

```json
{
  "result": "deleted",
  "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"
        ]
      }
    ]
  }
}
```

