elastic / elasticsearch-net

This strongly-typed, client library enables working with Elasticsearch. It is the official client maintained and supported by Elastic.
https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/index.html
Apache License 2.0
3.58k stars 1.15k forks source link

Option to override default NEST high-level client behavior for 404 status codes #5754

Open yevhen opened 3 years ago

yevhen commented 3 years ago

In our code, we heavily rely on ElasticClientException being thrown for requests made to missing documents/indices. While upgrading to 7.x we figured out that we need substantial changes to be made in too many places. Moreover, the previous behavior was easy to use with higher-order functions - you just catch ElasticClientException in top-level code and you're done. With new behavior, we need to augment low-level code everywhere to check for ResponseBase.IsValid property at the point of invocation which makes it non-composable and leads to ugly and verbose code (ala Go err checking).

Please, provide a global option for NEST high-level client, so that it doesn't override StatusCodeToResponseSuccess for 404 status codes.

stevejgordon commented 3 years ago

Hi @yevhen. Apologies for my delay in responding. I read this and thought I had left a note. I can see the benefit of this, particularly for upgrade scenarios as you have indicated. I'll need to spend some more time reviewing the finer details.