0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Elasticsearch: reindexが失敗した時の対応手順例

Posted at

reindexが失敗すると

reindex が失敗すると、GET _tasks/<reindex_task_id> のレスポンスで次のようなfailuresの情報が表示されます。

  "failures": [
    {
      "index": "dest_index",
      "id": "6e9cad7292a7133f74449b5f94ac1d",
      "cause": {
        "type": "status_exception",
        "reason": "Input too large. The tokenized input length [543] exceeds the maximum sequence length [512]"
      },
      "status": 400
    }
  ]

失敗したドキュメントの確認

レスポンスに含まれるfailures内の id は Document ID を表します。これを元に失敗したドキュメントを確認します。
* なお、Document ID は、reindexソースとターゲットで変更ありません。

GET /source_index/_doc/6e9cad7292a7133f74449b5f94ac1d

そのドキュメントを見て失敗の原因・対応が思い当たれば、その原因を取り除いてreindexを再実行します。

失敗した原因の調査

ドキュメントを見ただけでは失敗の原因・対応がはっきりしない場合は、_simulate APIを使って、reindexでのパイプライン処理をシミュレーションすることにより詳細な情報を得ることができます。verbose=true にすると、各プロセッサの前後でドキュメントがどう変化したかを確認できます。

_simulate API例
POST _ingest/pipeline/my_pipeline/_simulate?verbose=true
{
  "docs": [
    {
        "_index": "source_index",
        "_id": "6e9cad7292a7133f74449b5f94ac1d",
        "_source": { ここに該当ドキュメントの_sourceをコピペします }
   }
  ]
}

ドキュメント単位のreindex

特定のドキュメントだけを対象にreindexを実行することが可能です。失敗した原因を取り除いた後、次のように失敗したドキュメントだけを対象にreindexを実行し成功するかどうかを確認することができます。

POST _reindex
{
  "source": {
    "index": "source_index",
    "query": {
      "ids": {
        "values": ["6e9cad7292a7133f74449b5f94ac1d"]
      }
    }
  },
  "dest": {
    "index": "dest_index",
    "pipeline": "my_pipeline"
  }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?