Elasticsearch synonym mappings - illegal_argument_exception

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.

{
  "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"
          }
        }
      }
    }
  }
}

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.

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