使用elasticsearch进行远程索引时出错

k97glaaz  于 2021-06-13  发布在  ElasticSearch
关注(0)|答案(1)|浏览(345)

我正在尝试从一个es集群转移到另一个集群,以便计划更新。
两者都是相同的版本(6.4)。为此,我使用以下命令:

curl -XPOST  -H "Content-Type: application/json"  http://new_cluster/_reindex -d@reindex.json

reindex.json看起来是这样的:

{
  "source": {
    "remote": {
      "host": "http://old_cluster:9199"
    },
    "index": "megabase.33.2",
    "query": {
      "match_all": {}
      }
  },
  "dest": {
    "index": "megabase.33.2"
  }
}

我将一个新集群和一个旧集群列为白名单,它可以工作,但我不能进入数据迁移的末尾,因为我有这个错误,我不明白它在这里的含义:

{
   "took":1762,
   "timed_out":false,
   "total":8263428,
   "updated":5998,
   "created":5001,
   "deleted":0,
   "batches":11,
   "version_conflicts":0,
   "noops":0,
   "retries":{
      "bulk":0,
      "search":0
   },
   "throttled_millis":0,
   "requests_per_second":-1.0,
   "throttled_until_millis":0,
   "failures":[
      {
         "index":"megabase.33.2",
         "type":"persona",
         "id":"noYOA3IBTWbNbLJUqk6T",
         "cause":{
            "type":"mapper_parsing_exception",
            "reason":"failed to parse [adr_inse]",
            "caused_by":{
               "type":"illegal_argument_exception",
               "reason":"For input string: \"2A004\""
            }
         },
         "status":400
      }
   ]
}

原始群集中的记录如下所示:

{
  "took": 993,
  "timed_out": false,
  "_shards": {
    "total": 4,
    "successful": 4,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 0,
    "hits": [
      {
        "_index": "megabase.33.2",
        "_type": "persona",
        "_id": "noYOA3IBTWbNbLJUqk6T",
        "_score": 0,
        "_source": {
          "address": "Obfucated",
          "adr_inse": "2A004",
          "age": 10,
          "base": "Obfucated",
          "city": "Obfucated",
          "cp": 20167,
          "email_md5": "Obfucated",
          "fraicheur": "2020-01-12T19:39:04+01:00",
          "group": 1,
          "latlon": "Obfucated",
          "partner": "Obfucated",
          "partnerbase": 2,
          "sex": 2,
          "sms_md5": "Obfucated"
        }
      }
    ]
  }
}

你知道我做错了什么吗?
谢谢

g2ieeal7

g2ieeal71#

我们发现,当只使用reindex方法时,Map并没有很好地创建。
所以我删除了新的索引,使用elasticdump重新创建Map:

elasticdump --input=http://oldcluster/megabase.33.2 --output=http://newcluster/megabase.33.2 --type=mapping

然后运行上一个脚本,一切都完美无瑕(而且相当快)

相关问题