This is beneficial for readers who want to do the same in the new versions of NEST, v2.3 at the time of this writing. If you just need an answer, all you have to do is use ElasticLowLevelClient , according to the doc :
var responseJson = client.Search<string>(...);
But if you want to get typed results, then this is a bit more connected. You need to call DisableDirectStreaming() in the settings object and then extract the original json from response.ApiCall.ResponseBodyInBytes , as shown here .
var settings = new ConnectionSettings(new Uri("http://localhost:9200")) .DefaultIndex("index1") .DisableDirectStreaming(); var response = new ElasticClient(settings) .Search<object>(s => s.AllIndices().AllTypes().MatchAll()); if (response.ApiCall.ResponseBodyInBytes != null) { var responseJson = System.Text.Encoding.UTF8.GetString(response.ApiCall.ResponseBodyInBytes); }
source share