Error Handling while Adding Data


I have created a entity definition with a date time field. And if I'm entering any other value than date time type, then that record is not getting added into elastic and it is throwing an error. But I'm getting success Index response, with httpstatus code 200. But in Debug Info it is showing as errors:true . I want to throw an error whenever I'm getting a response like this from Elastic side. How can I do it.

Please find my debug Info here.
{ "took": 5, "errors": true, "items": [ { "index": { "_index": "RandomKey", "_type": "RandomKey", "_id": "RandomID", "status": 400, "error": { "type": "mapper_parsing_exception", "reason": "failed to parse [dtDateTime]", "caused_by": { "type": "illegal_argument_exception", "reason": "Invalid format: \"SOme Text for check\"" } } } } ] }

Column dtDateTime is a datetime column and I'm sending some text in this. I have added ThrowExceptions = true . but it is not throwing any Exception.

if you do a bulk index operation, you cannot rely on the response of the HTTP request, but you have to check each response item status field, like in your example it shows a 400 error, meaning that the client apparently some invalid data.

Thanks @spinscale, But is there any way I can access response items other than DebugInfo. Like any property of Response? or can we use the ElasticsearchClientException class? If we can use it, then can you give me an example in C#.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.