The library attempts to throw exceptions for common problems. These exceptions match the HTTP response code provided
by Elasticsearch. For example, attempting to GET a nonexistent document will throw a
Exceptions are a useful and consistent way to deal with problems like missing documents, syntax errors, version conflicts, etc. But sometimes you want to deal with the response body rather than catch exceptions (often useful in test suites).
If you need that behavior, you can configure an
ignore parameter. This should be configured in the
of the reuqest array. For example, this example will ignore the
exception and instead return the JSON provided by Elasticsearch.
You can specify multiple HTTP status codes to ignore, by providing an array of values:
It should be noted that the response is simply a string, which may or may not be encoded as JSON. In the first example, the response body was a complete JSON object which could be decoded. In the second example, it was simply a string.
Since the client has no way of knowing what the exception response will contain, no attempts to decode it are taken.