# How to make custom synonym analyzer?

**URL:** <https://discuss.elastic.co/t/how-to-make-custom-synonym-analyzer/357001>\
**Category:** Elasticsearch\
**Created:** [April 8, 2024, 4:37pm UTC](https://discuss.elastic.co/t/how-to-make-custom-synonym-analyzer/357001 "2024-04-08T16:37:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oerlikon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/oerlikon/32/131633_2.png) [@Oerlikon](https://discuss.elastic.co/u/Oerlikon)\
**Post date:** [April 8, 2024, 4:37pm UTC](https://discuss.elastic.co/t/how-to-make-custom-synonym-analyzer/357001/1 "2024-04-08T16:37:31Z")

</div>

I got this error

```auto
Traceback (most recent call last):
  File "C:\Users\User\PycharmProjects\pythonProject_full_text\Preprocesing_slovak_synonyms.py", line 91, in <module>
    es.indices.create(index=index_name, body=mapping)
  File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\elasticsearch\_sync\client\utils.py", line 402, in wrapped
    return api(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\elasticsearch\_sync\client\indices.py", line 493, in create
    return self.perform_request( # type: ignore[return-value]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\elasticsearch\_sync\client\_base.py", line 389, in perform_request
    return self._client.perform_request(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\elasticsearch\_sync\client\_base.py", line 320, in perform_request
    raise HTTP_EXCEPTIONS.get(meta.status, ApiError)(
elasticsearch.BadRequestError: BadRequestError(400, 'illegal_argument_exception', 'failed to build synonyms from [D://elasticsearch//elasticsearch-8.10.4-windows-x86_64//elasticsearch-8.10.4//config//slovak_synonyms.txt]')

```

When I try to run this mapping

```auto
"settings": {
        "analysis": {
            "filter": {
                "stop_word": {
                    "type": "stop",
                    "stopwords": stopwords_list
                },
                "syn_fil": {
                    "type": "synonym",
                    "synonyms_path": "D://elasticsearch//elasticsearch-8.10.4-windows-x86_64//elasticsearch-8.10.4//config//slovak_synonyms.txt"
            }
            },
            "analyzer": {
                "syn": {
                    "tokenizer": "simple",
                    "filter": ["lowercase", "asciifolding", "stop_word", "syn_fil"]
                }
            }
        }
    },
"mappings": {
        "properties": {
"text": {"type": "text", "analyzer": "syn"}
}
}

```

How can I fix it?

---

<div class="post-metadata">

**Author:** ![jessgarson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jessgarson/32/129841_2.png) [@jessgarson](https://discuss.elastic.co/u/jessgarson)\
**Post date:** [April 9, 2024, 4:26pm UTC](https://discuss.elastic.co/t/how-to-make-custom-synonym-analyzer/357001/2 "2024-04-09T16:26:41Z")

</div>

Thanks for reaching out, @Oerlikon

Would something like what's described in this [blog post](https://www.elastic.co/blog/boosting-the-power-of-elasticsearch-with-synonyms) work for you?
