How to set listener timeout by high level rest client?

Hello guys
based on the our previous problem I need read all documents in an Index with sorting. as it's data is somewhat big I confront with the search timeout.
here is the simplified code:

    RestHighLevelClient highLevelClient = new RestHighLevelClient(
            RestClient.builder(
                    new HttpHost("host1", port1, "http"),
                    new HttpHost("host2", port2, "http"))
    );
    // create SearchSourceBuilder
    SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
    searchSourceBuilder.query(QueryBuilders.matchAllQuery());
    searchSourceBuilder.size(5000);
    searchSourceBuilder.sort(new FieldSortBuilder("_uid").order(SortOrder.ASC));
    searchSourceBuilder.timeout(new TimeValue(10, TimeUnit.MINUTES));
    // create SearchRequest
    SearchRequest searchRequest = new SearchRequest("telemine");
    searchRequest.types("messages");
    searchRequest.source(searchSourceBuilder);
    searchRequest.scroll(new TimeValue(10, TimeUnit.MINUTES));
    // execute Search
    SearchResponse searchResponse = highLevelClient.search(searchRequest);

and here is the error

java.io.IOException: listener timeout after waiting for [30000] ms
at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:663)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:222)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:194)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:443)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:429)
at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:368)

I think sorting on 1.4 billions of data is time-consuming.
I'll be appreciated if someone could help to set listener timeout.
thanks

Hi,
you need to increase the maxRetryTimeout and the socket timeout when you initialize the low-level REST client, see https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/_timeouts.html .

Cheers
Luca

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.