# How to add synonym with a forward shash? Error failed to build synonyms

**URL:** <https://discuss.elastic.co/t/how-to-add-synonym-with-a-forward-shash-error-failed-to-build-synonyms/330647>\
**Category:** Elasticsearch\
**Created:** [April 24, 2023, 12:09pm UTC](https://discuss.elastic.co/t/how-to-add-synonym-with-a-forward-shash-error-failed-to-build-synonyms/330647 "2023-04-24T12:09:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eduard\_mart](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eduard_mart/32/119729_2.png) [@Eduard\_mart](https://discuss.elastic.co/u/Eduard_mart)\
**Post date:** [April 24, 2023, 12:09pm UTC](https://discuss.elastic.co/t/how-to-add-synonym-with-a-forward-shash-error-failed-to-build-synonyms/330647/1 "2023-04-24T12:09:45Z")

</div>

How to add synonym with a forward shash? Error failed to build synonyms.

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [April 24, 2023, 2:06pm UTC](https://discuss.elastic.co/t/how-to-add-synonym-with-a-forward-shash-error-failed-to-build-synonyms/330647/2 "2023-04-24T14:06:33Z")

</div>

Your problem is probably due to tokenization. This works for me:

```auto
DELETE my_index

PUT my_index
{
  "settings": {
    "analysis": {
      "filter": {        
        "my_synonym_filter": {
          "type": "synonym", 
          "synonyms": [ 
            "ac/dc => synonym_1"
          ]
        }
      },
      "analyzer": {
        "my_analyzer": {
          "tokenizer": "whitespace",
          "filter": [            
            "my_synonym_filter"
          ]
        }
      }
    }
  }
}

POST my_index/_analyze
{
  "analyzer" : "my_analyzer",    
  "text" : "ac/dc"  
}

```

produces:

```auto
{
    "tokens": [
        {
            "token": "synonym_1",
            "start_offset": 0,
            "end_offset": 5,
            "type": "SYNONYM",
            "position": 0
        }
    ]
}

```

---

<div class="post-metadata">

**Author:** ![Eduard\_mart](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eduard_mart/32/119729_2.png) [@Eduard\_mart](https://discuss.elastic.co/u/Eduard_mart)\
**Post date:** [May 3, 2023, 5:56am UTC](https://discuss.elastic.co/t/how-to-add-synonym-with-a-forward-shash-error-failed-to-build-synonyms/330647/3 "2023-05-03T05:56:04Z")

</div>

> [@cbuescher](#):
>
> ```auto
> "synonyms": [ 
> "ac/dc => synonym_1"
> ]
> 
> ```

Yep I tried

"ac/dc, acdc" - it give an error.

ac/dc also doesn't work.

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [May 3, 2023, 1:33pm UTC](https://discuss.elastic.co/t/how-to-add-synonym-with-a-forward-shash-error-failed-to-build-synonyms/330647/4 "2023-05-03T13:33:03Z")

</div>

You probably still use the "standard" tokenizer which will split the token on the slash. Also you didn't mention the error you are getting. The example I posted works for me, so in order to help here we'd need more information.

---

<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:** [May 31, 2023, 1:33pm UTC](https://discuss.elastic.co/t/how-to-add-synonym-with-a-forward-shash-error-failed-to-build-synonyms/330647/5 "2023-05-31T13:33:23Z")

</div>

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