-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Improve documentation #34700
Description
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();
}