In debugger i was able to look at the jSON query that is being sent to Elasticsearch in version 1.7.
After upgrading to v5.0, i cannot find the jSON query that is being sent to Elasticsearch.
You can see the json sent to and received from Elasticsearch by setting a few options on ConnectionSettings:
var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var connectionSettings = new ConnectionSettings(pool)
// pretty print all requests and responses to Elasticsearch
.PrettyJson()
// buffer the request and response bytes in MemoryStream
.DisableDirectStreaming()
// a delegate to run when a request completes. Use this to capture
// request and response information
.OnRequestCompleted(response =>
{
// log out the request
if (response.RequestBodyInBytes != null)
{
Console.WriteLine(
$"{response.HttpMethod} {response.Uri} \n" +
$"{Encoding.UTF8.GetString(response.RequestBodyInBytes)}");
}
else
{
Console.WriteLine($"{response.HttpMethod} {response.Uri}");
}
Console.WriteLine();
// log out the 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(connectionSettings);
Now with this in place, we can capture the request and responses. .DisableDirectStreaming() can also be set on a per-request basis so that request and response bytes are only buffered when necessary, as doing so will have an impact on performance.