是的,您可以很好地为每个查询级别定义超时,请参阅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