Skip to content

Commit

Permalink
Remove default-value parameters from non-core queries (#87813)
Browse files Browse the repository at this point in the history
This slims down the representations of all remaining queries not in the core

* percolate
* function_score
* script_score
* pinned

Relates to #76515
  • Loading branch information
romseygeek authored Jun 20, 2022
1 parent 0b37360 commit 26019f2
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.field(INDEXED_DOCUMENT_FIELD_VERSION.getPreferredName(), indexedDocumentVersion);
}
}
printBoostAndQueryName(builder);
boostAndQueryNameToXContent(builder);
builder.endObject();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,19 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
}
builder.endArray();

builder.field(SCORE_MODE_FIELD.getPreferredName(), scoreMode.name().toLowerCase(Locale.ROOT));
if (scoreMode != DEFAULT_SCORE_MODE) {
builder.field(SCORE_MODE_FIELD.getPreferredName(), scoreMode.name().toLowerCase(Locale.ROOT));
}
if (boostMode != null) {
builder.field(BOOST_MODE_FIELD.getPreferredName(), boostMode.name().toLowerCase(Locale.ROOT));
}
builder.field(MAX_BOOST_FIELD.getPreferredName(), maxBoost);
if (maxBoost != FunctionScoreQuery.DEFAULT_MAX_BOOST) {
builder.field(MAX_BOOST_FIELD.getPreferredName(), maxBoost);
}
if (minScore != null) {
builder.field(MIN_SCORE_FIELD.getPreferredName(), minScore);
}
printBoostAndQueryName(builder);
boostAndQueryNameToXContent(builder);
builder.endObject();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
if (minScore != null) {
builder.field(MIN_SCORE_FIELD.getPreferredName(), minScore);
}
printBoostAndQueryName(builder);
boostAndQueryNameToXContent(builder);
builder.endObject();
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {}
@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(NAME);
printBoostAndQueryName(builder);
boostAndQueryNameToXContent(builder);
builder.endObject();
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ public void testIdsFromJson() throws IOException {
}
}
},
"ids": [ "1", "2" ],
"boost": 1.0
"ids": [ "1", "2" ]
}
}""";

Expand All @@ -181,8 +180,7 @@ public void testDocsFromJson() throws IOException {
}
}
},
"docs": [ { "_index": "test", "_id": "1" }, { "_index": "test", "_id": "2" } ],
"boost": 1.0
"docs": [ { "_index": "test", "_id": "1" }, { "_index": "test", "_id": "2" } ]
}
}""";

Expand Down

0 comments on commit 26019f2

Please sign in to comment.