You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to reach out to ask for a possible enhancement request, please.
This project proposes a very nice abstraction through its wrapper.
For instance, the BulkRequest:
List<Product> products = fetchProducts();
BulkRequest.Builder br = new BulkRequest.Builder();
for (Product product : products) {
br.operations(op -> op
.index(idx -> idx
.index("products")
.id(product.getSku())
.document(product)
)
);
}
Would it be possible to enhance this in order to get the http request payload directly, please?
Something like bulkRequest.getRequestBody() which would allow getting the request and its body, without executing, instead of BulkResponse result = esClient.bulk(br.build()); which would execute the request.
This would allow the possibility to enrich the content of the request, and most of all, to be able to just get the request body and send it with other http client, such as Okhttp, Netty, etc... without being coupled with the default RestClient of this repo.
The text was updated successfully, but these errors were encountered:
patpatpat123
changed the title
[Feature Request] possibility to get request body
[Feature Request] possibility to get request body bulkRequest.getRequestBody()
Mar 30, 2023
swallez
changed the title
[Feature Request] possibility to get request body bulkRequest.getRequestBody()
Allow serializing requests independently from the transport
Apr 3, 2023
We generally want to avoid code that is specific for a particular request, as the need may actually apply to all of them.
Currently the serialization is handled within the Transport implementation. Bulk requests belong to a family of requests that are sent as nd-json (one json document per line). This is handled by RestClientTransport.writeNdJson() that you can copy in your code to use a different client.
A possible evolution is to extract this code in a separate class so that it can called not only by the transport class, but also any other application code. I've renamed the issue to reflect this.
"A possible evolution is to extract this code in a separate class so that it can called not only by the transport class, but also any other application code."
-> this is what I intended to say. Thank you for the correction. Looking forward to seeing this in the future, many thanks
Description
Hello, Elastic java team,
I wanted to reach out to ask for a possible enhancement request, please.
This project proposes a very nice abstraction through its wrapper.
For instance, the BulkRequest:
Would it be possible to enhance this in order to get the http request payload directly, please?
Something like
bulkRequest.getRequestBody()
which would allow getting the request and its body, without executing, instead ofBulkResponse result = esClient.bulk(br.build());
which would execute the request.This would allow the possibility to enrich the content of the request, and most of all, to be able to just get the request body and send it with other http client, such as Okhttp, Netty, etc... without being coupled with the default RestClient of this repo.
The text was updated successfully, but these errors were encountered: