Discard non-letter characters during Completion Suggestor indexing

Here's my index:

PUT autocomplete-food
{
  "mappings": {
    "properties": {
      "suggest": {
        "type": "completion"
      }
    }
  }
}

Adding a document to this index:

PUT autocomplete-food/_doc/1?refresh
{
  "suggest": [
    {
      "input": "Starbucks",
      "weight": 10
    },
    {
      "input": ["+(Coffee","Latte","Flat White"],
      "weight": 5
    }
  ]
}

Search query for suggestions:

POST autocomplete-food/_search?pretty
{
  "suggest": {
    "suggest": {
      "prefix": "coff",        
      "completion": {         
          "field": "suggest"
      }
    }
  }
}

Search result:

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [ ]
  },
  "suggest" : {
    "suggest" : [
      {
        "text" : "coff",
        "offset" : 0,
        "length" : 4,
        "options" : [
          {
            "text" : "+(Coffee",
            "_index" : "autocomplete-food",
            "_type" : "_doc",
            "_id" : "1",
            "_score" : 5.0,
            "_source" : {
              "suggest" : [
                {
                  "input" : "Starbucks",
                  "weight" : 10
                },
                {
                  "input" : [
                    "+(Coffee",
                    "Latte",
                    "Flat White"
                  ],
                  "weight" : 5
                }
              ]
            }
          }
        ]
      }
    ]
  }
}

Notice the "text" value is "+(Coffee". I don't want to index/get the non-letter characters. I was expecting that as the default analyzer is "simple" analyzer, this won't happen. But the "input" field in the response also contains the special characters.

How do I achieve discarding the non-letter characters?
P.S - Elasticsearch version 7.17

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