1

下面是 Rest 客户端初始化。

RestHighLevelClient client = new 
RestHighLevelClient(RestClient.builder(httpHost).setRequestConfigCallback(
    requestConfigBuilder -> requestConfigBuilder
        .setConnectTimeout(30000)
        .setSocketTimeout(90000));

有没有办法在重新初始化其余客户端的情况下即时更改超时值?

4

1 回答 1

1

是的,您可以很好地为每个查询级别定义超时,请参阅JHLRC中可用的超时方法,可以在查询级别添加。

因此,您查询的示例 java 代码看起来像

SearchRequest searchRequest = new SearchRequest(USERS_INDEX_NAME);
        BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
        boolQueryBuilder.minimumShouldMatch(1);
        MatchQueryBuilder emailMatchQueryBuilder = new MatchQueryBuilder("emailId", email);
        MatchQueryBuilder userIdMatchQueryBuilder = new MatchQueryBuilder("userId", userId);
        MatchQueryBuilder mobileMatchQueryBuilder = new MatchQueryBuilder("mobileNumber", mobile);
        boolQueryBuilder.should(emailMatchQueryBuilder);
        boolQueryBuilder.should(userIdMatchQueryBuilder);
        boolQueryBuilder.should(mobileMatchQueryBuilder);

        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.timeout(new TimeValue(1000)); // note this
于 2020-12-31T09:35:02.833 回答