Improve SearchHit "equals" implementation for null fields cases (#50327) (#50448)

* Improve SearchHit "equals" implementation for null fields cases
This commit is contained in:
Aleksandr Maus 2019-12-23 09:59:07 -05:00 committed by GitHub
parent cec02da0ac
commit d5cec7faa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -906,7 +906,7 @@ public final class SearchHit implements Writeable, ToXContentObject, Iterable<Do
&& Objects.equals(seqNo, other.seqNo)
&& Objects.equals(primaryTerm, other.primaryTerm)
&& Objects.equals(source, other.source)
&& Objects.equals(fields, other.fields)
&& Objects.equals(getFields(), other.getFields())
&& Objects.equals(getHighlightFields(), other.getHighlightFields())
&& Arrays.equals(matchedQueries, other.matchedQueries)
&& Objects.equals(explanation, other.explanation)

View File

@ -73,9 +73,12 @@ public class SearchHitTests extends AbstractWireSerializingTestCase<SearchHit> {
if (randomBoolean()) {
nestedIdentity = NestedIdentityTests.createTestItem(randomIntBetween(0, 2));
}
Map<String, DocumentField> fields = new HashMap<>();
if (randomBoolean()) {
fields = GetResultTests.randomDocumentFields(xContentType).v2();
Map<String, DocumentField> fields = null;
if (frequently()) {
fields = new HashMap<>();
if (randomBoolean()) {
fields = GetResultTests.randomDocumentFields(xContentType).v2();
}
}
SearchHit hit = new SearchHit(internalId, uid, type, nestedIdentity, fields);
if (frequently()) {