【问题标题】:I can not change the analyzer and mapping at already existing index我无法在现有索引处更改分析器和映射
【发布时间】:2014-09-21 02:12:49
【问题描述】:

我想更改 elasticsearch 中现有索引的设置和映射。但是,我得到了错误。

curl -XPOST localhost:9200/myindex/_close

{"已确认":true}

curl -XPUT localhost:9200/myindex/_settings -d '{
 "index": {
   "analysis": {
     "analyzer": {
      "custom_analyzer": {
       "type": "custom",
       "tokenizer": "keyword",
       "filter": ["lowercase"]
      }
     }
    }
   }
 }'

{"已确认":true}

curl -XPUT localhost:9200/myindex/mytype/_mapping -d '{
 "properties": {
  "myfield": {
       "type": "string",
       "search_analyzer": "custom_analyzer",
       "index_analyzer": "custom_analyzer"
  }
 }
}'

{"error":"MergeMappingException[Merge failed with failures {[mapper [myfield] has different index_analyzer]}]","status":400}

我做错了什么?

【问题讨论】:

  • 如果在现有类型中引入了新字段,您始终可以添加映射。要获得更好的方法,您可以通过修改映射将一种索引类型的数据传输到另一种新类型。
  • 我明白,必须为我想要的内容重新索引。

标签: elasticsearch


【解决方案1】:

所有索引都存储为不可变的,因此您必须重新索引数据。

零停机版本。 1

要重新索引,您可以按照以下步骤操作:

  • 使用所需设置/映射创建索引
  • 使用 _bulk API 将数据从旧索引拉到新索引

零停机时间版本。 2

或者您可以使用所需的设置/映射创建一个新索引,并为新创建的索引创建一个别名(使用旧索引名称)。

需要停机

最后一种方法是关闭索引,进行更改并重新打开索引。

【讨论】:

  • 如上所述,在关闭索引后设置设置时出现错误。
猜你喜欢
  • 2012-09-04
  • 1970-01-01
  • 1970-01-01
  • 2019-04-16
  • 2013-07-08
  • 1970-01-01
  • 2015-04-20
  • 2017-10-25
  • 2023-04-11
相关资源
最近更新 更多