Converting bytes to SearchResponse

I am working on a network streaming application and also works as a thin proxy server on top of elasticsearch. The application basically does is query on the ES cluster and then streams the response to a client application.

            XContentBuilder xContentBuilder = XContentFactory.jsonBuilder();
            xContentBuilder.startObject();
            response.toXContent(xContentBuilder, ToXContent.EMPTY_PARAMS);
            xContentBuilder.endObject();

bytes[] responseStreamBytes = xContentBuilder.bytes().toBytes();

The client side application should do is get the stream and convert the bytes array stream to SearchResponse again.
How can this be done ?

i have done is use yse readFrom from SearchResponse class. However, it gives a error like

java.io.IOException: Can't read unknown type [121]
at org.elasticsearch.common.io.stream.StreamInput.readGenericValue(StreamInput.java:433)
at org.elasticsearch.common.io.stream.StreamInput.readMap(StreamInput.java:352)
at org.elasticsearch.transport.TransportMessage.readFrom(TransportMessage.java:55)
at org.elasticsearch.action.ActionResponse.readFrom(ActionResponse.java:35)
at org.elasticsearch.action.search.SearchResponse.readFrom(SearchResponse.java:201)

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.