That one is for the internal serialization protocol. It is how nodes talk to one another but isn't super useful to you. It leaks into the Transport client because the Transport client uses the same code base as the rest of Elasticsearch.
I think you want QueryBuilders#wrapperQuery. But it doesn't take the whole search request body, only the stuff in the query clause. The rest of the search request body there isn't a thing for. Inside Elasticsearch we use RestSearchAction#parseSearchRequest to do the parsing but takes a bunch of parameters that aren't built for the transport client.
This change came about because we parse the search request on the coordinating node which means the guts of SearchSourceBuilder had to change totally. Again, this leaks into the transport client because the transport client is the same code as the Elasticsearch server.
Maybe you could look at SearchTemplateRequest. It is part of the mustache module in 5.0 but that comes with the transport client dependency. You'd use it like this. If you declare the template as "inline" and you don't have any mustache in it ({{ or }}) then it should pass through cleanly.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.