Prior to 2.0 it was possible to set ExposeRawResponse on the ConnectionSettings to keep a copy of the raw response on the result object for debugging. In addition, on the result object you could inspect ConnectionSettings to see the response.
Both of these methods are missing now and there's nothing in the documentation.
var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var settings = new ConnectionSettings(connectionPool, new InMemoryConnection())
.DefaultIndex("default-index")
.DisableDirectStreaming()
.OnRequestCompleted(response =>
{
// log out the request and the request body, if one exists for the type of request
if (response.RequestBodyInBytes != null)
{
Console.WriteLine(
$"{response.HttpMethod} {response.Uri} \n" +
$"{Encoding.UTF8.GetString(response.RequestBodyInBytes)}");
}
else
{
Console.WriteLine($"{response.HttpMethod} {response.Uri}");
}
// log out the response and the response body, if one exists for the type of response
if (response.ResponseBodyInBytes != null)
{
Console.WriteLine($"Status: {response.HttpStatusCode}\n" +
$"{Encoding.UTF8.GetString(response.ResponseBodyInBytes)}\n" +
$"{new string('-', 30)}\n");
}
else
{
Console.WriteLine($"Status: {response.HttpStatusCode}\n" +
$"{new string('-', 30)}\n");
}
});
var client = new ElasticClient(settings);
If you just want to inspect the response ad-hoc, then set DisableDirectStreaming and then get the string from the response body bytes
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.