在 ElasticSearch 设置中更新分析器

Updating analyzer within ElasticSearch settings

我正在使用 Sense(Chrome 插件)并且我已经成功地设置了一个分析器并且它工作正常。如果我对设置发出 GET (/media/_settings),将返回以下内容。

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

我正在尝试通过执行以下操作来更新它:

关闭索引

发出此 PUT 命令(删除过滤器)

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

打开索引

但是当设置回来时,过滤器并没有被删除。分析器创建后不能更新吗?

简答:否

更长的答案。来自 ES 文档:

"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."

最好的方法是创建一个新索引,然后移动您的数据。有些客户有帮手为您做这件事,但这不是标准 Java 客户的一部分。

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