Update version in SearchHits transport serialization

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
This commit is contained in:
Luca Cavanna 2018-12-17 12:53:43 +01:00
parent ec0dc2c0e9
commit 1aad08c0c0
2 changed files with 6 additions and 10 deletions

View File

@ -243,8 +243,7 @@ public final class SearchHits implements Streamable, ToXContentFragment, Iterabl
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);
@ -265,8 +264,7 @@ public final class SearchHits implements Streamable, ToXContentFragment, Iterabl
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);

View File

@ -271,10 +271,9 @@ public class SearchHitsTests extends AbstractStreamableXContentTestCase<SearchHi
}
}
//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);
@ -288,9 +287,8 @@ public class SearchHitsTests extends AbstractStreamableXContentTestCase<SearchHi
}
}
//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());