9

I'm using Sense (Chrome plugin) and I've managed to setup an analyzer and it is working correctly. If I issue a GET (/media/_settings) on the settings the following is returned.

{
   "media": {
      "settings": {
         "index": {
            "creation_date": "1424971612982",
            "analysis": {
               "analyzer": {
                  "folding": {
                     "filter": [
                        "lowercase",
                        "asciifolding"
                     ],
                     "tokenizer": "standard"
                  }
               }
            },
            "number_of_shards": "5",
            "uuid": "ks98Z6YCQzKj-ng0hU7U4w",
            "version": {
               "created": "1040499"
            },
            "number_of_replicas": "1"
         }
      }
   }
}

I am trying to update it by doing the following:

Closing the index

Issuing this PUT command (removing a filter)

PUT /media/_settings
{
  "settings": {
    "analysis": {
      "analyzer": {
        "folding": {
          "tokenizer": "standard",
          "filter":  [ "lowercase" ]
        }
      }
    }
  }
}

Opening the index

But when the settings come back, the filter is not removed. Can you not update an analyzer once you've created it?

Mark Walsh
  • 3,241
  • 1
  • 24
  • 46

1 Answers1

17

Short answer: No.

Longer answer. From the ES docs:

"Although you can add new types to an index, or add new fields to a type, you can’t add new analyzers or make changes to existing fields. If you were to do so, the data that had already been indexed would be incorrect and your searches would no longer work as expected."

Best way is to create a new index, and move your data. Some clients have helpers to do this for you, but it's not part of the standard Java client.

http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/reindex.html

sksamuel
  • 16,154
  • 8
  • 60
  • 108
  • I suspected that, this will help me though - http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/index-aliases.html – Mark Walsh Feb 27 '15 at 10:07
  • 1
    That won't help you with the movement of data - you'll still need to write something to move stuff from a to b, before you then remap your alias to b. If you're in Scala https://github.com/sksamuel/elastic4s has a helper for this. – sksamuel Feb 27 '15 at 10:21
  • Yes sorry, I should of been more explicit. Basically, from day 1, you should use an alias for your index and you can use the scan and scroll and bulk API to push your data in if you need to make changes, is what I am getting from your answers and the documentation. – Mark Walsh Feb 27 '15 at 10:23
  • 1
    Yep, you still have to do some logic to loop over the scroll yourself, rather than there being some internal command you can execute – sksamuel Mar 01 '15 at 22:16