Skip to content

Commit

Permalink
Update version in SearchHits transport serialization
Browse files Browse the repository at this point in the history
Now that #36555 is backported to 6.x, the version in the transport serialization conditionals for sort and collapse info can be updated to 6.6.0
  • Loading branch information
javanna committed Dec 18, 2018
1 parent ec0dc2c commit 1aad08c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
6 changes: 2 additions & 4 deletions server/src/main/java/org/elasticsearch/search/SearchHits.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,7 @@ public void readFrom(StreamInput in) throws IOException {
hits[i] = SearchHit.readSearchHit(in);
}
}
//TODO update version once backported
if (in.getVersion().onOrAfter(Version.V_7_0_0)) {
if (in.getVersion().onOrAfter(Version.V_6_6_0)) {
sortFields = in.readOptionalArray(Lucene::readSortField, SortField[]::new);
collapseField = in.readOptionalString();
collapseValues = in.readOptionalArray(Lucene::readSortValue, Object[]::new);
Expand All @@ -265,8 +264,7 @@ public void writeTo(StreamOutput out) throws IOException {
hit.writeTo(out);
}
}
//TODO update version once backported
if (out.getVersion().onOrAfter(Version.V_7_0_0)) {
if (out.getVersion().onOrAfter(Version.V_6_6_0)) {
out.writeOptionalArray(Lucene::writeSortField, sortFields);
out.writeOptionalString(collapseField);
out.writeOptionalArray(Lucene::writeSortValue, collapseValues);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,9 @@ public void testFromXContentWithShards() throws IOException {
}
}

//TODO rename method and adapt versions after backport
public void testReadFromPre70() throws IOException {
public void testReadFromPre6_6_0() throws IOException {
try (StreamInput in = StreamInput.wrap(Base64.getDecoder().decode("AQC/gAAAAAA="))) {
in.setVersion(VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_7_0_0)));
in.setVersion(VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_6_6_0)));
SearchHits searchHits = new SearchHits();
searchHits.readFrom(in);
assertEquals(0, searchHits.getHits().length);
Expand All @@ -288,9 +287,8 @@ public void testReadFromPre70() throws IOException {
}
}

//TODO rename method and adapt versions after backport
public void testSerializationPre70() throws IOException {
Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_7_0_0));
public void testSerializationPre6_6_0() throws IOException {
Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_6_6_0));
SearchHits original = createTestItem(randomFrom(XContentType.values()), false, true, TotalHits.Relation.EQUAL_TO);
SearchHits deserialized = copyInstance(original, version);
assertArrayEquals(original.getHits(), deserialized.getHits());
Expand Down

0 comments on commit 1aad08c

Please sign in to comment.