Skip to content

Allow serializing requests independently from the transport #546

Open
@patpatpat123

Description

@patpatpat123

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions