Skip to content

Commit 563e1fb

Browse files
authored
[Rest Api Compatibility] Return adjust_pure_negative values (#75182)
the adjust_pure_negative value used to be always present in to_xcontent response, but it was changed in #49543 to only serialise this field when the value is false relates #51816
1 parent 45e38b5 commit 563e1fb

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

rest-api-spec/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ tasks.named("yamlRestCompatTest").configure {
107107
'search/260_parameter_validation/test size=-1 is deprecated', //size=-1 change
108108
'search/310_match_bool_prefix/multi_match multiple fields with cutoff_frequency throws exception', //cutoff_frequency
109109
'search/340_type_query/type query', // type_query - probably should behave like match_all
110-
'search_shards/10_basic/Search shards aliases with and without filters',
111110
] + v7compatibilityNotSupportedTests())
112111
.join(',')
113112
}

server/src/main/java/org/elasticsearch/index/query/BoolQueryBuilder.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.elasticsearch.common.xcontent.ObjectParser;
2222
import org.elasticsearch.common.xcontent.XContentBuilder;
2323
import org.elasticsearch.common.xcontent.XContentParser;
24+
import org.elasticsearch.core.RestApiVersion;
2425

2526
import java.io.IOException;
2627
import java.util.ArrayList;
@@ -251,7 +252,9 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
251252
doXArrayContent(FILTER, filterClauses, builder, params);
252253
doXArrayContent(MUST_NOT, mustNotClauses, builder, params);
253254
doXArrayContent(SHOULD, shouldClauses, builder, params);
254-
if (adjustPureNegative != ADJUST_PURE_NEGATIVE_DEFAULT) {
255+
if (builder.getRestApiVersion() == RestApiVersion.V_7) {
256+
builder.field(ADJUST_PURE_NEGATIVE.getPreferredName(), adjustPureNegative);
257+
} else if (adjustPureNegative != ADJUST_PURE_NEGATIVE_DEFAULT) {
255258
builder.field(ADJUST_PURE_NEGATIVE.getPreferredName(), adjustPureNegative);
256259
}
257260
if (minimumShouldMatch != null) {

0 commit comments

Comments
 (0)