Hi,
We are updating Elastic document using ES python client, and facing below issue during the update.
TransportError(400, u'illegal_argument_exception', u'[93f58351-0db1-423e-ae5c-ebb1c3dea103][172.17.0.2:9300][indices:data/write/update[s]]')
Update is being done using scripts (painless lang), We tried many times this update on same kind of documents and it fails for random data. But when we run the same script which is failed to update manually (using REST client), it works fine.
Below is the sample document which we are trying to update.
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 2.4849067,
"hits": [
{
"_index": "nexus",
"_type": "nexus",
"_id": "QQXOqGIBFnY0FvUDvj8x",
"_score": 2.4849067,
"_source": {
"timestamp": "2018-04-09 08:09:03",
"artifacts": [
{
"artifact_type": "pom",
"group_id": "com.core",
"artifact_id": "product_bom_reactor",
"artifact_version": "test_225"
},
{
"artifact_type": "pom",
"group_id": "com.core",
"artifact_id": "product_sdk",
"artifact_version": "test_225"
},
{
"artifact_type": "jar",
"group_id": "com.core",
"artifact_classifier": "jacoco-full-report",
"artifact_id": "product_ut",
"artifact_version": "test_225"
},
{
"artifact_type": "ear",
"group_id": "com.core",
"artifact_classifier": "rm_sec",
"artifact_id": "product_ear",
"artifact_version": "test_225"
},
{
"artifact_type": "ear",
"group_id": "com.core",
"artifact_classifier": "rm_nosec",
"artifact_id": "product_ear",
"artifact_version": "test_225"
},
{
"artifact_type": "pom",
"group_id": "com.core",
"artifact_id": "product_bom",
"artifact_version": "test_225"
},
{
"artifact_type": "pom",
"group_id": "com.core",
"artifact_id": "product_reactor",
"artifact_version": "test_225"
}
]
}
}
]
}
}
For each element in _source.artifacts below script runs, which updates the elements with new fields,
if artifact_classifier is None:
body = {
"script": {
"source": "for(int i=0; i<ctx._source.artifacts.length; i++) { if(ctx._source.artifacts[i].group_id == '" + group_id + "' && ctx._source.artifacts[i].artifact_id == '" + artifact_id + "' && ctx._source.artifacts[i].artifact_version == '" + artifact_version + "' && ctx._source.artifacts[i].artifact_type == '" + artifact_type + "'){ctx._source.artifacts[i].is_deleted = '" + str(
is_deleted) + "'; ctx._source.artifacts[i].deletion_timestamp = '" + str(
now) + "'}}",
"lang": "painless"
}
}
else:
body = {
"script": {
"source": "for(int i=0; i<ctx._source.artifacts.length; i++) { if(ctx._source.artifacts[i].group_id == '" + group_id + "' && ctx._source.artifacts[i].artifact_id == '" + artifact_id + "' && ctx._source.artifacts[i].artifact_version == '" + artifact_version + "' && ctx._source.artifacts[i].artifact_type == '" + artifact_type + "' && ctx._source.artifacts[i].artifact_classifier == '" + artifact_classifier + "'){ctx._source.artifacts[i].is_deleted = '" + str(
is_deleted) + "'; ctx._source.artifacts[i].deletion_timestamp = '" + str(
now) + "'}}",
"lang": "painless"
}
}
Environment :
Elasticsearch, PythonClient 6.1.1
Why do we get this error randomly ?
Thanks in Advance,