I wanted to reindex an index called test_dupes_2year_double
to combine a date
field and a time
field to add new field datetime
to a new index called datetime_srldc
.
POST _reindex
{
"source": {
"index": "test_dupes_2year_double"
},
"dest": {
"index": "datetime_srldc"
},
"script": {
"lang": "painless",
"source": """
int valuee = 0;
valuee=(int)((Long.parseUnsignedLong(ctx._source.time_stamp))/1000000000);
int p1 = valuee % 60;
int p2 = valuee / 60;
int p3 = p2 % 60;
p2 = p2 / 60;
String s1;
if (p2<=9 || p3<=9) {
if (p2<=9 && p3<=9) {
s1 = "0" + Integer.toString(p2) + ":" + "0" + Integer.toString(p3) + ":" + Integer.toString(p1) + "0";
}
else if (p2<=9) {
s1 = "0" + Integer.toString(p2) + ":" + Integer.toString(p3) + ":" + Integer.toString(p1) + "0";
}
else if(p3<=9) {
s1 = Integer.toString(p2) + ":" + "0" + Integer.toString(p3) + ":" + Integer.toString(p1) + "0";
}
}
else {
s1 = Integer.toString(p2) + ":" + Integer.toString(p3) + ":" + Integer.toString(p1) + "0";
}
ctx._source.time=s1;
s1 = ctx._source.date + "T" + s1 + ".000Z";
ctx._source.datetime=s1;
"""
}
}
But the reindexing used to give timeout error, so I increased the timeout limit. then it took some time and finally gave following error. Though it ended up with an error, the new index was created with partial data.
Error:
{
"took": 24858,
"timed_out": false,
"total": 845750,
"updated": 0,
"created": 8000,
"deleted": 0,
"batches": 9,
"version_conflicts": 0,
"noops": 0,
"retries": {
"bulk": 0,
"search": 0
},
"throttled_millis": 0,
"requests_per_second": -1,
"throttled_until_millis": 0,
"failures": [
{
"index": "datetime_srldc",
"type": "_doc",
"id": "fEZDy24BMbXag5rgCsZv",
"cause": {
"type": "cluster_block_exception",
"reason": "index [datetime_srldc] blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"
},
"status": 403
},
{
"index": "datetime_srldc",
"type": "_doc",
"id": "fUZDy24BMbXag5rgCsZv",
"cause": {
"type": "cluster_block_exception",
"reason": "index [datetime_srldc] blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"
},
"status": 403
},
The reindexed index has partial data as you can see bellow. So what is wrong with this?. What is the solution?.
GET _cat/indices/
yellow open test_dupes_2year_double gfIHThEiTIuHUk_Yf4PWfA 1 1 845750 0 1.4gb 1.4gb
yellow open datetime_srldc Ybxm0BYIS4646hM7E8AYNQ 1 1 48000 0 87.5mb 87.5mb