SteveLin100132
5/5/2020 - 2:27 AM

ElasticSearch Reindex API

ElasticSearch Reindex API

POST _reindex

{
  "source": {
    "index": "twitter"
  },
  "dest": {
    "index": "new_twitter"
  }
}

Remote Reindex

POST _reindex

{
  "source": {
    "remote": {
      "host": "http://127.0.0.1:9200"
    },
    "index": "faoms_wks_2020-10",
    "type": "sfcusn"
  },
  "dest": {
    "index": "faoms_sfcusn_2020-10",
    "version_type": "external"
  },
  "conflicts": "proceed"
}

Script Reindex

POST _reindex

{
  "source": {
    "remote": {
      "host": "http://127.0.0.1:9200"
    },
    "index": "faoms_wks_2020-10",
    "type": "sfcusn"
  },
  "dest": {
    "index": "faoms_sfcusn_2020-10",
    "version_type": "external"
  },
  "conflicts": "proceed",
   "script": {
    "lang": "painless",
    "source": "ctx._source.line = ctx._source.evt_data.line; ctx._source.mcno = ctx._source.evt_data.stationName.replace('NPM-', ''); ctx._source.byPass = ctx._source.evt_data.standardTime == 0; ctx._source.remove('evt_ns');  ctx._id = ctx._source.plant + '_' + ctx._source.line; ctx._type = ctx._source.plant; ctx._index = ctx._index.replace('smtct_stdcycletime', 'smtcycletime_bypass'); "
  }
}