在ElasticSearch设置中更新分析器 [英] Updating analyzer within ElasticSearch settings

查看:151
本文介绍了在ElasticSearch设置中更新分析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Sense(Chrome插件),并且设法设置了分析仪,并且该分析仪正常工作。如果我在设置上发出GET(/ media / _settings),则会返回以下内容。

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:

关闭索引

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

Issuing this PUT command (removing a filter)

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

打开索引

但是,当设置恢复时,不会删除过滤器。创建分析器后,是否可以不对其进行更新?

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

推荐答案

简短答案:否。

更长的答案。从ES文档中:

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

最好的方法是创建一个新索引并移动数据。一些客户可以为您执行帮助,但这不是标准Java客户端的一部分。

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

这篇关于在ElasticSearch设置中更新分析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆