# Using synonyms file in Elastic Cloud

**URL:** <https://discuss.elastic.co/t/using-synonyms-file-in-elastic-cloud/301136>\
**Category:** Elasticsearch\
**Created:** [March 30, 2022, 5:53pm UTC](https://discuss.elastic.co/t/using-synonyms-file-in-elastic-cloud/301136 "2022-03-30T17:53:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Conor\_Hennessy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/conor_hennessy/32/91354_2.png) [@Conor\_Hennessy](https://discuss.elastic.co/u/Conor_Hennessy)\
**Post date:** [March 30, 2022, 5:53pm UTC](https://discuss.elastic.co/t/using-synonyms-file-in-elastic-cloud/301136/1 "2022-03-30T17:53:46Z")

</div>

Hi,

In order to use synonyms in Elasticsearch, we can use a .txt file with a list of our synonyms and add the path to this file in our index definition. See below as an example:

```auto
PUT /test_index
{
  "settings": {
    "index": {
      "analysis": {
        "analyzer": {
          "synonym": {
            "tokenizer": "whitespace",
            "filter": ["synonym"]
          }
        },
        "filter": {
          "synonym": {
            "type": "synonym",
            "synonyms_path": "analysis/synonym.txt"
          }
        }
      }
    }
  }
}

```

As per the documentation, the process to update this file when using Elastic Cloud is as follows:

1. Create the extension where we will store a zipped synonyms file. [See here](https://www.elastic.co/guide/en/cloud/current/ec-custom-bundles.html#ec_method_1_use_http_post_to_create_metadata_and_then_upload_the_file_using_http_put)

```auto
curl -XPOST \
 -H "Authorization: ApiKey $EC_API_KEY" \
 -H 'content-type:application/json' \
 https://api.elastic-cloud.com/api/v1/deployments/extensions \
 -d'{
   "name" : "synonyms-v1",
   "description" : "The best synonyms ever",
   "extension_type" : "bundle",
   "version" : "7.*"
 }'

```

1. Send a zipped synonyms file to the extension

```auto
curl -XPUT \
-H "Authorization: ApiKey $EC_API_KEY" \
"https://api.elastic-cloud.com/api/v1/deployments/extensions/$extension_id" \
-T /tmp/synonyms.zip

```

1. Add the new extension and update the deployment (plan change), either via api or through the elastic cloud console. [See here](https://www.elastic.co/guide/en/cloud/current/Deployment_-_CRUD.html#update-deployment). We would like to do this via api.

By following the process outlined above, we managed to successfully add a synonyms file to our deployment, but each time, one of our nodes (we have 2 data nodes and a tiebreaker) stops during the process. The error received is of "unknown" type.

`{ "failure_type": "ClusterFailure:InstancesAreNotStopped", "InstanceId(ElasticsearchId(xxxx),NodeName(tiebreaker-xxxx))": "FailedToStop(Allocation [xxxx] failed with unknown error)" }`

We had to ask technical support to restart the nodes.

Afterwards, now that the extension containing the synonyms file had already been added to the deployment, we updated the file and performed a rolling reset (instead of the deployment plan upgrade call mentioned in step 3. above, [see here](https://www.elastic.co/guide/en/cloud-enterprise/3.0/restart-deployment-es-resource.html)) with the command below :

`POST /api/v1/deployments/{deployment_id}/elasticsearch/{ref_id}/_restart`

The data in our data nodes begin to transfer to the new instances, but the step `Calling Elasticsearch node shutdown API` has been frozen for 24 hours.

Has anyone worked with synonyms in Elastic Cloud? Is this really the only solution to use synonyms in elastic cloud? Restarting/updating full deployments has proven to be a risky procedure for us. We want to use synonyms on an important production environment and can't risk such issues.

Kind regards,  
Conor

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 27, 2022, 5:54pm UTC](https://discuss.elastic.co/t/using-synonyms-file-in-elastic-cloud/301136/2 "2022-04-27T17:54:18Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
