# Elasticsearch synonym mappings - illegal\_argument\_exception

**URL:** <https://discuss.elastic.co/t/elasticsearch-synonym-mappings-illegal-argument-exception/335746>\
**Category:** Elasticsearch\
**Created:** [June 12, 2023, 8:56am UTC](https://discuss.elastic.co/t/elasticsearch-synonym-mappings-illegal-argument-exception/335746 "2023-06-12T08:56:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacques\_du\_Plessis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jacques_du_plessis/32/35413_2.png) [@Jacques\_du\_Plessis](https://discuss.elastic.co/u/Jacques_du_Plessis)\
**Post date:** [June 12, 2023, 8:56am UTC](https://discuss.elastic.co/t/elasticsearch-synonym-mappings-illegal-argument-exception/335746/1 "2023-06-12T08:56:55Z")

</div>

is there a way to tell the mappings to ignore the synonym file if it does not exist?  
currently i always have to make sure that the synonym file exist, but just wondering of there is a way to ignore it if its not there, and if it is there use it.

The below is how my mappings look.

```auto
{
  "settings": {
    "analysis": {
      "analyzer": {
        "edge_ngram_analyzer": {
          "tokenizer": "edge_ngram_tokenizer",
          "filter": [
            "lowercase",
            "ascii_folding"
          ]
        },
        "englishAnalyzer": {
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "trim",
            "ascii_folding"
          ]
        },
        "my_synonym_analyzer": {
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "trim",
            "ascii_folding",
            "my_synonyms"
          ]
        }
      },
      "tokenizer": {
        "edge_ngram_tokenizer": {
          "type": "edge_ngram",
          "min_gram": 3,
          "max_gram": 20,
          "token_chars": [
            "letter",
            "digit",
            "symbol",
            "punctuation"
          ]
        }
      },
      "filter": {
        "ascii_folding": {
          "type": "asciifolding",
          "preserve_original": true
        },
        "my_synonyms": {
          "type": "synonym",
          "synonyms_path": "synonym.txt"
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "userId": {
        "type": "keyword"
      },
      "text": {
        "type": "text",
        "fields": {
          "search-as-you-type": {
            "type": "search_as_you_type"
          },
          "edgengram": {
            "type": "text",
            "analyzer": "edge_ngram_analyzer"
          }
        },
        "analyzer": "my_synonym_analyzer"
      },
      "url": {
        "type": "text",
        "index": false
      },
      "breadcrumb": {
        "type": "text",
        "fields": {
          "search-as-you-type": {
            "type": "search_as_you_type"
          },
          "edgengram": {
            "type": "text",
            "analyzer": "edge_ngram_analyzer"
          }
        }
      }
    }
  }
}

```

---

<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:** [June 13, 2023, 8:25am UTC](https://discuss.elastic.co/t/elasticsearch-synonym-mappings-illegal-argument-exception/335746/2 "2023-06-13T08:25:35Z")

</div>

No there isn't. The idea of the exception is to raise awareness that the mapping you specified (including the synonym filter) isn't working as expected. If you temporarily want no synonyms, you need to supply an empty file.

---

<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:** [July 11, 2023, 8:25am UTC](https://discuss.elastic.co/t/elasticsearch-synonym-mappings-illegal-argument-exception/335746/3 "2023-07-11T08:25:37Z")

</div>

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