Kibana 重新索引期间ElasticsearchMap更改

5cg8jx4n  于 5个月前  发布在  Kibana
关注(0)|答案(3)|浏览(74)

在Elasticsearch中执行重索引时,字段的Map会发生变化。
先前Map:

"status": {
    "type": "keyword",
    "ignore_above": 10
}

字符串
新Map:

"status": {
    "type": "text",
    "fields": {
        "keyword": {
            "type": "keyword",
            "ignore_above": 256
        }
    }
}


用于执行重新索引的命令,导致Map更改:

POST _reindex
{
  "source": {
    "index": "source_index_name"
  },
  "dest": {
    "index": "new_index_name"
  }
}


Elasticsearch版本:7.13.2
Map应该被保留。在重新建立索引时,有什么方法可以保留原始Map吗?

brvekthn

brvekthn1#

在重新建立索引时,只有数据被复制到新索引,而原始索引的Map和设置都不会被复制到新索引。
如果您想保留原始索引的Map,则需要预先使用所需的Map创建新的目标索引,然后才运行reindex操作。

hzbexzde

hzbexzde2#

重新索引要求为源中的所有文档启用_source。
在调用_reindex之前,应该根据需要配置目标。Reindex不会从源或其关联模板复制设置。

Map、分片数、副本等需要提前配置。https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html

像瓦尔提到的其中一个方法是提前PUTMap如下:

PUT reindex_destination
{
  "mappings": {
    "properties": {
      "status": {
        "type": "keyword",
        "ignore_above": 10
      }
    }
  }
}

字符串
---并触发重新索引。

POST _reindex?slices=auto&wait_for_completion=false
{
  "conflicts": "proceed", 
  "source": {
    "index": "reindex_source"
  },
  "dest": {
    "index": "reindex_destination"
  }
}

要自动执行PUTMap过程,可以使用index templates

PUT /_index_template/reindex_template?pretty
{
  "index_patterns": [
    "reindex_*"
  ],
  "template": {
    "settings": {
      "number_of_shards": 1
    },
    "mappings": {
      "properties": {
        "status": {
          "type": "keyword",
          "ignore_above": 10
        }
      }
    }
  }
}

dsekswqp

dsekswqp3#

在Elasticsearch中执行重索引时,Map由目标索引确定。
若要保留原始Map,请在重新索引之前显式定义目标索引的Map,确保它与源索引的Map匹配。

相关问题