Skip to content

Improve documentation #34700

@wangzhenhui1992

Description

@wangzhenhui1992

Describe the feature:
As the document is shown on elastic website below:
https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-low-usage-requests.html#java-rest-low-usage-request-options

Using the code below , we should be able to create a RequestOptions,but it had a compile error because of HeapBufferedResponseConsumerFactory.

The source in RestClientDocumentation.java is right of course because it imported the class withimport HttpAsyncResponseConsumerFactory.HeapBufferedResponseConsumerFactory

But for developers it will not be automatically imported in Eclipse. and I need to read the ElasticSearch java resource to find and import the class or go to github to read the sample.

So, I want to improve it and make it more developer friendly that every beginner can use it with copy simply.

Code on website

private static final RequestOptions COMMON_OPTIONS;
static {
    RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
    builder.addHeader("Authorization", "Bearer " + TOKEN); 
    builder.setHttpAsyncResponseConsumerFactory(           
        new HeapBufferedResponseConsumerFactory(30 * 1024 * 1024 * 1024));
    COMMON_OPTIONS = builder.build();
}

Code in RestClientDocumentation.java

import org.elasticsearch.client.HttpAsyncResponseConsumerFactory.HeapBufferedResponseConsumerFactory;
...
...
private static final RequestOptions COMMON_OPTIONS;
static {
    RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
    builder.addHeader("Authorization", "Bearer " + TOKEN); 
    builder.setHttpAsyncResponseConsumerFactory(           
        new HeapBufferedResponseConsumerFactory(30 * 1024 * 1024 * 1024));
    COMMON_OPTIONS = builder.build();
}

Code modified

import org.elasticsearch.client.HttpAsyncResponseConsumerFactory.;
...
...
private static final RequestOptions COMMON_OPTIONS;
static {
    RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
    builder.addHeader("Authorization", "Bearer " + TOKEN); 
    builder.setHttpAsyncResponseConsumerFactory(           
        new HttpAsyncResponseConsumerFactory.HeapBufferedResponseConsumerFactory(30 * 1024 * 1024 * 1024));
    COMMON_OPTIONS = builder.build();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    >docsGeneral docs changes

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions