spring-data-elasticsearch icon indicating copy to clipboard operation
spring-data-elasticsearch copied to clipboard

Add the possibility to define custom request options / transport options.

Open fazaza opened this issue 2 years ago • 1 comments

it's possible to override the DEFAULT_BUFFER_LIMIT of 100Mb in ElasticsearchRestTemplate

in all queries of ElasticsearchRestTemplate we are using RequestOptions.DEFAULT

execute(client -> client.index(request, RequestOptions.DEFAULT));

and the RequestOptions.DEFAULT contain hardcoded value of 100Mb

RequestOptions.DEFAULT is -->  new Builder(
            Collections.emptyList(), Collections.emptyMap(), HeapBufferedResponseConsumerFactory.DEFAULT, null, null).build();

    class HeapBufferedResponseConsumerFactory implements HttpAsyncResponseConsumerFactory {

        //default buffer limit is 100MB
        static final int DEFAULT_BUFFER_LIMIT = 100 * 1024 * 1024;

fazaza avatar May 13 '22 15:05 fazaza

This currently is not possible. I change the title of the issue to reflect what this is about.

Comment: When using the old RestHighLevelClient had the possibility to get request options, Spring Data Elasticsearch currently uses org.elasticsearch.client.RequestOptions.DEFAULT. The new Elasticsearch client can have transport options set on the Transport. It should be possible for the user to provide her own default request/transport options.

sothawo avatar May 13 '22 19:05 sothawo

When using the configuration class as described in the documentation (https://github.com/spring-projects/spring-data-elasticsearch/blob/main/src/main/asciidoc/reference/elasticsearch-clients.adoc#imperative-rest-client), it is possible to provide user defined co.elastic.clients.transport.TransportOptions which will be added by the transport to each request.

So this is available in the current main branch for the next version.

sothawo avatar Oct 15 '22 11:10 sothawo