How to make custom synonym analyzer?

I got this error

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

"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?

Thanks for reaching out, @Oerlikon

Would something like what's described in this blog post work for you?