Hello,
I am facing the following issue
Steps:
-
I am creating without problem the following ingest pipeline:
PUT _ingest/pipeline/alexpipeline { "description" : "calculate for the field http.request.body.original the number of articles", "processors" : [ { "script" : { "source": """ ctx.number_of_articles = ctx.http.request.body.original.items.length; """ } } ] }
-
I am creating without problem the following index:
PUT /test3 { "settings": { "number_of_shards": 1, "number_of_replicas": 1, "default_pipeline": "alexpipeline" }, "mappings": { "properties": { "http": { "properties": { "request": { "properties": { "body": { "properties": { "original": { "type": "nested", "properties": { "ArticleNr": { "type": "text" }, "items": { "type": "nested", "properties": { "articleId": { "type": "text" }, "quantity": { "type": "text" } } } } } } } } } } } } } }
-
I try to index the following document
PUT /test3/_doc/1
{"http.request.body.original":
{"ArticleNr":"471776","sendMethod":"TOUR","partialDelivery":false,"isTourTimetable":false,"deliveryAddressId":"1000000028658646379","items":[{"articleId":1001223455,"quantity":1},{"articleId":1001058014,"quantity":1},{"articleId":1001058015,"quantity":1},{"articleId":1001058019,"quantity":1},{"articleId":1001058017,"quantity":1}]}
}
BUT i get the exact error message below:
{
"error" : {
"root_cause" : [
{
"type" : "script_exception",
"reason" : "runtime error",
"script_stack" : [
"ctx.number_of_articles = ctx.http.request.body.original.items.length;\r\n \r\n ",
" ^---- HERE"
],
"script" : " ...",
"lang" : "painless",
"position" : {
"offset" : 60,
"start" : 27,
"end" : 118
}
}
],
"type" : "script_exception",
"reason" : "runtime error",
"script_stack" : [
"ctx.number_of_articles = ctx.http.request.body.original.items.length;\r\n \r\n ",
" ^---- HERE"
],
"script" : " ...",
"lang" : "painless",
"position" : {
"offset" : 60,
"start" : 27,
"end" : 118
},
"caused_by" : {
"type" : "null_pointer_exception",
"reason" : "Cannot invoke \"Object.getClass()\" because \"callArgs[0]\" is null"
}
},
"status" : 400
}
How can i change the ingest pipeline code so that doesnt throw an error when trying to index my field?
IMPORTANT NOTE: If i dont use the ingest pipeline in the index settings and try to index the document no problem occurs. So i believe i must change something in my ingest pipeline script....
Best regards,
Alexandros