Search in sources :

Example 6 with NestedIdentity

use of org.elasticsearch.search.SearchHit.NestedIdentity in project elasticsearch by elastic.

the class NestedIdentityTests method testSerialization.

public void testSerialization() throws IOException {
    NestedIdentity nestedIdentity = createTestItem(randomInt(3));
    try (BytesStreamOutput output = new BytesStreamOutput()) {
        nestedIdentity.writeTo(output);
        try (StreamInput in = output.bytes().streamInput()) {
            NestedIdentity deserializedCopy = new NestedIdentity(in);
            assertEquals(nestedIdentity, deserializedCopy);
            assertEquals(nestedIdentity.hashCode(), deserializedCopy.hashCode());
            assertNotSame(nestedIdentity, deserializedCopy);
        }
    }
}
Also used : StreamInput(org.elasticsearch.common.io.stream.StreamInput) NestedIdentity(org.elasticsearch.search.SearchHit.NestedIdentity) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput)

Aggregations

NestedIdentity (org.elasticsearch.search.SearchHit.NestedIdentity)6 ArrayList (java.util.ArrayList)2 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Supplier (java.util.function.Supplier)1 BytesStreamOutput (org.elasticsearch.common.io.stream.BytesStreamOutput)1 StreamInput (org.elasticsearch.common.io.stream.StreamInput)1 Text (org.elasticsearch.common.text.Text)1 XContentParser (org.elasticsearch.common.xcontent.XContentParser)1 XContentType (org.elasticsearch.common.xcontent.XContentType)1 Index (org.elasticsearch.index.Index)1 ShardId (org.elasticsearch.index.shard.ShardId)1 HighlightField (org.elasticsearch.search.fetch.subphase.highlight.HighlightField)1