When the standard typed OpenSearch APIs are too restrictive, use OpenSearchGenericClient to communicate with OpenSearch clusters or nodes via generic HTTP requests and responses.
By default, the generic client returns responses exactly as received from the server without interpreting status codes. You can configure it to throw an OpenSearchClientException for non-successful HTTP status codes using ClientOptions.throwOnHttpErrors().
Important: Always use a try-with-resources block when handling Response objects to ensure that underlying resources like input streams and buffers are properly closed.
// Get the generic client
final OpenSearchGenericClient generic = javaClient().generic();
// Get a generic client that throws exceptions on HTTP errors
final OpenSearchGenericClient genericWithErrorHandling = javaClient().generic().witClientOptions(ClientOptions.throwOnHttpErrors());