15

I'm new to Elasticsearch and I was wondering if it's possible to delete a custom analyzer or a custom filter from an index.

For example, imagine the following index settings:

    "settings" : {
        "analysis": {
            "filter":{
                "filter_metaphone":{
                    "encoder": "metaphone",
                    "type": "phonetic",
                    "replace": "false"
                },
                "filter_unused":{
                    "type": "edgeNGram",
                    "max_gram": "10",
                    "min_gram": "1" 
                }
            },
            "analyzer":{
                "name":{
                    "type": "custom",
                    "filter": ["filter_metaphone"],
                    "tokenizer": "standard"
                }
            }
        }   
    }

Is there any way to delete the filter "filter_unused" via curl without removing and creating the index with a new settings configuration?

Ricardo
  • 3,696
  • 5
  • 36
  • 50
user2970458
  • 151
  • 1
  • 3
  • what happens if you just re-post it without the filter_unused? – mconlin Nov 10 '13 at 13:48
  • looking at the ES code I only see GET and POST methods in the REST analyze actions, no DELETE. – mconlin Nov 10 '13 at 13:55
  • 1
    http://stackoverflow.com/questions/12367877/change-settings-and-mappings-on-existing-index-in-elasticsearch Here you can see how to change analyzer settings of existing index. – slawek Jul 09 '15 at 15:40

2 Answers2

4

After setting all values to null, the analyzer has disappeared for me (ES 6.8, 7.x, 8.x)

{
  "analysis": {
    "analyzer": {
      "my_search_analyzer" : {
        "filter" : null,
        "tokenizer" : null
      }
    }
  }
}

See Reset an index setting doc.

Ricardo
  • 3,696
  • 5
  • 36
  • 50
Oleg Skr
  • 386
  • 2
  • 9
  • This will not work anymore in ES 7.14. Setting to `null` will cause an exception. – loretoparisi Sep 20 '21 at 21:38
  • @loretoparisi that is not correct; it still works on 7.x or 8.x; you may need to set the fields that are using this analyzer to use another one or `null` before resetting the analyzer. Think like deleting a row in a DB table where other table has with foreign keys linked to this row... – Ricardo Nov 08 '22 at 20:21
1

No, there is not a way to delete one specific analyzer from an index setting at this time.

You could add new analyzers though. That API is documented here.

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-update-settings.html#indices-update-settings

Andy
  • 8,841
  • 8
  • 45
  • 68
  • 1
    looks like for ES5.x.x this has been solved with https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html – estoy Sep 04 '17 at 13:01