elasticsearch prodデータを1.4.3vから5.5vに移行しています。そのために私はreindexを使用しています。私は新しいESインデックスに古いESインデックスのインデックスを再作成しようとするとインデックスの再作成は、ESでの例外を除いてESの5.5Vでtask_historyインデックスの1.4.3v弾性検索データがマッピングと一致しません
{
"task_history": {
"mappings": {
"task_run_hist": {
"_all": {
"enabled": false
},
"_routing": {
"required": true,
"path": "org_id"
},
"properties": {
"RUN_TIME_IN_MINS": {
"type": "double"
},
"THROUGHPUT_ROWS_PER_SEC": {
"type": "long"
},
"account_name": {
"type": "string",
"index": "not_analyzed",
"store": true
}
}
}
}
}
}
ESマッピングを(task_historyインデックスのFailed Reason: mapper [THROUGHPUT_ROWS_PER_SEC] cannot be changed from type [long] to [float]. Failed Type: illegal_argument_exception
ESマッピングに失敗しますこのマッピングは)
{
"task_history": {
"mappings": {
"task_run_hist": {
"_all": {
"enabled": false
},
"_routing": {
"required": true
},
"properties": {
"RUN_TIME_IN_MINS": {
"type": "float"
},
"THROUGHPUT_ROWS_PER_SEC": {
"type": "long"
},
"account_name": {
"type": "keyword",
"store": true
}
}
}
}
}
}
サンプル・データ
{
"_index": "task_history",
"_type": "task_run_hist",
"_id": "1421955143",
"_score": 1,
"_source": {
"RUN_TIME_IN_MINS": 0.47,
"THROUGHPUT_ROWS_PER_SEC": 46,
"org_id": "xxxxxx",
"account_name": "Soma Acc1"
}
},
{
"_index": "task_history",
"_type": "task_run_hist",
"_id": "1421943738",
"_score": 1,
"_source": {
"RUN_TIME_IN_MINS": 1.02,
"THROUGHPUT_ROWS_PER_SEC": 65.28,
"org_id": "yyyyyy",
"account_name": "Choma Acc1"
}
}
を再インデックス一環として作成されます
2質問
THROUGHPUT_ROWS_PER_SEC
タイプのマッピングがlong
ときにどのようにelasticsearch 1.4.3は、浮動小数点数を保存していますか?- 古いESのデータ問題の場合は、どのように再インデックスプロセスを開始する前にすべての浮動小数点数を削除できますか?第二のオプションについては
私は一度確認し、それを削除することができるように、クエリの下に使用して浮動小数点数を有するすべてのドキュメントを一覧表示しようとしているが、クエリの下にまだ非浮動小数点数としてTHROUGHPUT_ROWS_PER_SEC
を持つドキュメントを一覧表示しています。
注:Groovyのスクリプティング
GET task_history/task_run_hist/_search?size=100
{
"filter": {
"script": {
"script": "doc['THROUGHPUT_ROWS_PER_SEC'].value % 1 == 0"
}
}
}
ヴァルが提供するソリューションで更新
を有効になっている私は、インデックスの再作成にスクリプトの下にしようとすると、私はランタイムエラーを取得します。以下に記載されています。何がここで騒がしくなっているのか?元のスクリプトがRUN_TIME_IN_MINS
フィールドにエラーを指摘したので、RUN_TIME_IN_MINS
をfloatに変換する条件を追加しました。 mapper [RUN_TIME_IN_MINS] cannot be changed from type [long] to [float]"
POST _reindex?wait_for_completion=false
{
"source": {
"remote": {
"host": "http://esip:15000"
},
"index": "task_history"
},
"dest": {
"index": "task_history"
},
"script": {
"inline": "if (ctx._source.THROUGHPUT_ROWS_PER_SEC % 1 != 0) { ctx.op = 'noop' } ctx._source.RUN_TIME_IN_MINS = (float) ctx._source.RUN_TIME_IN_MINS;",
"lang": "painless"
}
}
ランタイムエラー
{
"completed": true,
"task": {
"node": "wZOzypYlSayIRlhp9y3lVA",
"id": 645528,
"type": "transport",
"action": "indices:data/write/reindex",
"status": {
"total": 18249521,
"updated": 4691,
"created": 181721,
"deleted": 0,
"batches": 37,
"version_conflicts": 0,
"noops": 67076,
"retries": {
"bulk": 0,
"search": 0
},
"throttled_millis": 0,
"requests_per_second": -1,
"throttled_until_millis": 0
},
"description": """
reindex from [host=esip port=15000 query={
"match_all" : {
"boost" : 1.0
}
}][task_history] updated with Script{type=inline, lang='painless', idOrCode='if (ctx._source.THROUGHPUT_ROWS_PER_SEC % 1 != 0) { ctx.op = 'noop' } ctx._source.RUN_TIME_IN_MINS = (float) ctx._source.RUN_TIME_IN_MINS;', options={}, params={}} to [task_history]
""",
"start_time_in_millis": 1502336063507,
"running_time_in_nanos": 93094657751,
"cancellable": true
},
"error": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [],
"script": "if (ctx._source.THROUGHPUT_ROWS_PER_SEC % 1 != 0) { ctx.op = 'noop' } ctx._source.RUN_TIME_IN_MINS = (float) ctx._source.RUN_TIME_IN_MINS;",
"lang": "painless",
"caused_by": {
"type": "null_pointer_exception",
"reason": null
}
}
}
それは非常に多くの可能性あなたはES 1.xの中に作成された非常に最初の文書が長い値(46、 ''「THROUGHPUT_ROWS_PER_SEC」を参照)を持っていたことです基礎。その後、すべての後続の値(浮動小数点数を問わず)は強制的にlongに強制されます。あなたは再インデックスプロセスを開始する前にES 5 **でマッピングを作成する必要があります。 – Val
@Val:この場合、浮動小数点数を持つドキュメントは例外をスローし、再インデックス処理を中止し、マッピングは正しいです。 long型でなければなりません。 – abi1964
異なる値に対応するために、あなたのES 5.xマッピングで 'double'を設定する必要があります。 – Val