Skip to content

Commit

Permalink
Do not send default ignore_throttled parameter since it is deprecated (
Browse files Browse the repository at this point in the history
  • Loading branch information
wiggzz authored Mar 10, 2022
1 parent e7fa335 commit 4c41c7a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,9 @@ Params withIndicesOptions(IndicesOptions indicesOptions) {
expandWildcards = joiner.toString();
}
putParam("expand_wildcards", expandWildcards);
putParam("ignore_throttled", Boolean.toString(indicesOptions.ignoreThrottled()));
if (indicesOptions.ignoreThrottled() == false) {
putParam("ignore_throttled", Boolean.toString(indicesOptions.ignoreThrottled()));
}
}
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1773,7 +1773,10 @@ public void testFieldCaps() throws IOException {
endpoint.add("_field_caps");

assertEquals(endpoint.toString(), request.getEndpoint());
int expectedSize = FieldCapabilitiesRequest.DEFAULT_INDICES_OPTIONS.equals(fieldCapabilitiesRequest.indicesOptions()) ? 1 : 5;
int expectedSize = expectedParameterCount(
FieldCapabilitiesRequest.DEFAULT_INDICES_OPTIONS,
fieldCapabilitiesRequest.indicesOptions()
);
assertEquals(expectedSize, request.getParameters().size());

// Note that we don't check the field param value explicitly, as field names are
Expand Down Expand Up @@ -1814,7 +1817,10 @@ public void testFieldCapsWithIndexFilter() throws IOException {
endpoint.add("_field_caps");

assertEquals(endpoint.toString(), request.getEndpoint());
int expectedSize = FieldCapabilitiesRequest.DEFAULT_INDICES_OPTIONS.equals(fieldCapabilitiesRequest.indicesOptions()) ? 1 : 5;
int expectedSize = expectedParameterCount(
FieldCapabilitiesRequest.DEFAULT_INDICES_OPTIONS,
fieldCapabilitiesRequest.indicesOptions()
);
assertEquals(expectedSize, request.getParameters().size());

// Note that we don't check the field param value explicitly, as field names are
Expand Down Expand Up @@ -1855,7 +1861,7 @@ public void testRankEval() throws Exception {
}
endpoint.add(RestRankEvalAction.ENDPOINT);
assertEquals(endpoint.toString(), request.getEndpoint());
int expectedSize = SearchRequest.DEFAULT_INDICES_OPTIONS.equals(rankEvalRequest.indicesOptions()) ? 1 : 5;
int expectedSize = expectedParameterCount(SearchRequest.DEFAULT_INDICES_OPTIONS, rankEvalRequest.indicesOptions());
assertEquals(expectedSize, request.getParameters().size());
assertEquals(expectedParams, request.getParameters());
assertToXContentBody(spec, request.getEntity());
Expand Down Expand Up @@ -2241,7 +2247,9 @@ public static void setRandomIndicesOptions(
} else {
expectedParams.put("expand_wildcards", "none");
}
expectedParams.put("ignore_throttled", Boolean.toString(getter.get().ignoreThrottled()));
if (getter.get().ignoreThrottled() == false) {
expectedParams.put("ignore_throttled", Boolean.toString(getter.get().ignoreThrottled()));
}
}

static IndicesOptions setRandomIndicesOptions(IndicesOptions indicesOptions, Map<String, String> expectedParams) {
Expand All @@ -2268,10 +2276,16 @@ static IndicesOptions setRandomIndicesOptions(IndicesOptions indicesOptions, Map
} else {
expectedParams.put("expand_wildcards", "none");
}
expectedParams.put("ignore_throttled", Boolean.toString(indicesOptions.ignoreThrottled()));
if (indicesOptions.ignoreThrottled() == false) {
expectedParams.put("ignore_throttled", Boolean.toString(indicesOptions.ignoreThrottled()));
}
return indicesOptions;
}

static int expectedParameterCount(IndicesOptions defaultOptions, IndicesOptions indicesOptions) {
return defaultOptions.equals(indicesOptions) ? 1 : indicesOptions.ignoreThrottled() ? 4 : 5;
}

static void setRandomIncludeDefaults(Consumer<Boolean> setter, Map<String, String> expectedParams) {
if (randomBoolean()) {
boolean includeDefaults = randomBoolean();
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog/84827.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 84827
summary: Do not send default ignore_throttled parameter since it is deprecated
area: Java High Level REST Client
type: bug
issues: []

0 comments on commit 4c41c7a

Please sign in to comment.