Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove default values from term and span query xcontent #86985

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ public void testFromJson() throws IOException {
"query" : {
"term" : {
"tag" : {
"value" : "something",
"boost" : 1.0
"value" : "something"
}
}
},
Expand All @@ -218,8 +217,7 @@ public void testParseDefaultsRemoved() throws IOException {
"query" : {
"term" : {
"tag" : {
"value" : "something",
"boost" : 1.0
"value" : "something"
}
}
},
Expand All @@ -235,8 +233,7 @@ public void testParseDefaultsRemoved() throws IOException {
"query" : {
"term" : {
"tag" : {
"value" : "something",
"boost" : 1.0
"value" : "something"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion rest-api-spec/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.internal.info.BuildParams

apply plugin: 'elasticsearch.build'
apply plugin: 'elasticsearch.publish'
Expand Down Expand Up @@ -76,6 +75,7 @@ tasks.named("yamlRestTestV7CompatTransform").configure { task ->
task.skipTest("search/340_type_query/type query", "#47207 type query throws exception in compatible mode")
task.skipTest("search.aggregation/210_top_hits_nested_metric/top_hits aggregation with sequence numbers", "#42809 the use nested path and filter sort throws an exception")
task.skipTest("search/310_match_bool_prefix/multi_match multiple fields with cutoff_frequency throws exception", "#42654 cutoff_frequency, common terms are not supported. Throwing an exception")
task.skipTest("search_shards/10_basic/Search shards aliases with and without filters", "Filter representation no longer outputs default boosts")
task.skipTest("search.aggregation/20_terms/string profiler via global ordinals filters implementation", "The profiler results aren't backwards compatible.")
task.skipTest("search.aggregation/20_terms/string profiler via global ordinals native implementation", "The profiler results aren't backwards compatible.")
task.skipTest("search.aggregation/20_terms/string profiler via map", "The profiler results aren't backwards compatible.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
- match: { shards.0.0.index: test_index }
- match: { indices.test_index.aliases: [test_alias_filter_1] }
- match: { indices.test_index.filter.term.field.value: value1 }
- lte: { indices.test_index.filter.term.field.boost: 1.0 }
- gte: { indices.test_index.filter.term.field.boost: 1.0 }

- do:
search_shards:
Expand All @@ -65,12 +63,6 @@
- match: { shards.0.0.index: test_index }
- match: { indices.test_index.aliases: [test_alias_filter_1, test_alias_filter_2]}
- length: { indices.test_index.filter.bool.should: 2 }
- lte: { indices.test_index.filter.bool.should.0.term.field.boost: 1.0 }
- gte: { indices.test_index.filter.bool.should.0.term.field.boost: 1.0 }
- lte: { indices.test_index.filter.bool.should.1.term.field.boost: 1.0 }
- gte: { indices.test_index.filter.bool.should.1.term.field.boost: 1.0 }
- lte: { indices.test_index.filter.bool.boost: 1.0 }
- gte: { indices.test_index.filter.bool.boost: 1.0 }

- do:
search_shards:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public void testFilteringAliases() throws Exception {
ClusterState clusterState = admin().cluster().prepareState().get().getState();
IndexMetadata indexMd = clusterState.metadata().index("test");
assertThat(indexMd.getAliases().get("alias1").filter().string(), equalTo("""
{"term":{"user":{"value":"kimchy","boost":1.0}}}"""));
{"term":{"user":{"value":"kimchy"}}}"""));

}

Expand Down Expand Up @@ -799,7 +799,7 @@ public void testSameAlias() {
IndexAbstraction ia = metadata.getIndicesLookup().get("alias1");
AliasMetadata aliasMetadata = AliasMetadata.getFirstAliasMetadata(metadata, ia);
assertThat(aliasMetadata.getFilter().toString(), equalTo("""
{"term":{"name":{"value":"bar","boost":1.0}}}"""));
{"term":{"name":{"value":"bar"}}}"""));

logger.info("--> deleting alias1");
stopWatch.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.startObject(fieldName);
builder.field(VALUE_FIELD.getPreferredName(), maybeConvertToString(this.value));
addExtraXContent(builder, params);
printBoostAndQueryName(builder);
boostAndQueryNameToXContent(builder);
builder.endObject();
builder.endObject();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.field(QUERY_FIELD.getPreferredName());
queryBuilder.toXContent(builder, params);
builder.field(FIELD_FIELD.getPreferredName(), fieldName);
printBoostAndQueryName(builder);
boostAndQueryNameToXContent(builder);
builder.endObject();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
big.toXContent(builder, params);
builder.field(LITTLE_FIELD.getPreferredName());
little.toXContent(builder, params);
printBoostAndQueryName(builder);
boostAndQueryNameToXContent(builder);
builder.endObject();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.field(MATCH_FIELD.getPreferredName());
matchBuilder.toXContent(builder, params);
builder.field(END_FIELD.getPreferredName(), end);
printBoostAndQueryName(builder);
boostAndQueryNameToXContent(builder);
builder.endObject();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.startObject(NAME);
builder.field(MATCH_FIELD.getPreferredName());
multiTermQueryBuilder.toXContent(builder, params);
printBoostAndQueryName(builder);
boostAndQueryNameToXContent(builder);
builder.endObject();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endArray();
builder.field(SLOP_FIELD.getPreferredName(), slop);
builder.field(IN_ORDER_FIELD.getPreferredName(), inOrder);
printBoostAndQueryName(builder);
boostAndQueryNameToXContent(builder);
builder.endObject();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,13 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
include.toXContent(builder, params);
builder.field(EXCLUDE_FIELD.getPreferredName());
exclude.toXContent(builder, params);
builder.field(PRE_FIELD.getPreferredName(), pre);
builder.field(POST_FIELD.getPreferredName(), post);
printBoostAndQueryName(builder);
if (pre != DEFAULT_PRE) {
builder.field(PRE_FIELD.getPreferredName(), pre);
}
if (post != DEFAULT_POST) {
builder.field(POST_FIELD.getPreferredName(), post);
}
boostAndQueryNameToXContent(builder);
builder.endObject();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
clause.toXContent(builder, params);
}
builder.endArray();
printBoostAndQueryName(builder);
boostAndQueryNameToXContent(builder);
builder.endObject();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.field(LITTLE_FIELD.getPreferredName());
little.toXContent(builder, params);

printBoostAndQueryName(builder);
boostAndQueryNameToXContent(builder);

builder.endObject();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ public void testToXContent() throws IOException {
{ "index_filter": {
"term": {
"field": {
"value": "value",
"boost": 1.0
"value": "value"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,14 @@ public void testFromJson() throws IOException {
+ " \"must\" : [ {"
+ " \"term\" : {"
+ " \"user\" : {"
+ " \"value\" : \"kimchy\","
+ " \"boost\" : 1.0"
+ " \"value\" : \"kimchy\""
+ " }"
+ " }"
+ " } ],"
+ " \"filter\" : [ {"
+ " \"term\" : {"
+ " \"tag\" : {"
+ " \"value\" : \"tech\","
+ " \"boost\" : 1.0"
+ " \"value\" : \"tech\""
+ " }"
+ " }"
+ " } ],"
Expand All @@ -241,15 +239,13 @@ public void testFromJson() throws IOException {
+ " \"should\" : [ {"
+ " \"term\" : {"
+ " \"tag\" : {"
+ " \"value\" : \"wow\","
+ " \"boost\" : 1.0"
+ " \"value\" : \"wow\""
+ " }"
+ " }"
+ " }, {"
+ " \"term\" : {"
+ " \"tag\" : {"
+ " \"value\" : \"elasticsearch\","
+ " \"boost\" : 1.0"
+ " \"value\" : \"elasticsearch\""
+ " }"
+ " }"
+ " } ],"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,13 @@ public void testFromJson() throws IOException {
"queries" : [ {
"term" : {
"age" : {
"value" : 34,
"boost" : 1.0
"value" : 34
}
}
}, {
"term" : {
"age" : {
"value" : 35,
"boost" : 1.0
"value" : 35
}
}
} ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,24 @@ public void testFromJson() throws IOException {
"clauses" : [ {
"span_term" : {
"field1" : {
"value" : "bar",
"boost" : 1.0
"value" : "bar"
}
}
}, {
"span_term" : {
"field1" : {
"value" : "baz",
"boost" : 1.0
"value" : "baz"
}
}
} ],
"slop" : 5,
"in_order" : true,
"boost" : 1.0
"in_order" : true
}
},
"little" : {
"span_term" : {
"field1" : {
"value" : "foo",
"boost" : 1.0
"value" : "foo"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,11 @@ public void testFromJson() throws IOException {
"match" : {
"span_term" : {
"user" : {
"value" : "kimchy",
"boost" : 1.0
"value" : "kimchy"
}
}
},
"end" : 3,
"boost" : 1.0
"end" : 3
}
}""";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ public void testFromJson() throws IOException {
"clauses" : [ {
"span_term" : {
"field" : {
"value" : "value1",
"boost" : 1.0
"value" : "value1"
}
}
}, {
Expand All @@ -89,14 +88,12 @@ public void testFromJson() throws IOException {
}, {
"span_term" : {
"field" : {
"value" : "value3",
"boost" : 1.0
"value" : "value3"
}
}
} ],
"slop" : 12,
"in_order" : false,
"boost" : 1.0
"in_order" : false
}
}""";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ public void testFromJson() throws IOException {
"boost" : 1.08
}
}
},
"boost" : 1.0
}
}
}""";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,19 @@ public void testFromJson() throws IOException {
"clauses" : [ {
"span_term" : {
"field" : {
"value" : "value1",
"boost" : 1.0
"value" : "value1"
}
}
}, {
"span_term" : {
"field" : {
"value" : "value2",
"boost" : 1.0
"value" : "value2"
}
}
}, {
"span_term" : {
"field" : {
"value" : "value3",
"boost" : 1.0
"value" : "value3"
}
}
} ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ public void testFromJson() throws IOException {
"include" : {
"span_term" : {
"field1" : {
"value" : "hoya",
"boost" : 1.0
"value" : "hoya"
}
}
},
Expand All @@ -178,25 +177,20 @@ public void testFromJson() throws IOException {
"clauses" : [ {
"span_term" : {
"field1" : {
"value" : "la",
"boost" : 1.0
"value" : "la"
}
}
}, {
"span_term" : {
"field1" : {
"value" : "hoya",
"boost" : 1.0
"value" : "hoya"
}
}
} ],
"slop" : 0,
"in_order" : true,
"boost" : 1.0
"in_order" : true
}
},
"pre" : 0,
"post" : 0,
"boost" : 2.0
}
}""";
Expand Down
Loading