Debug informationedit

Every response from Elasticsearch.Net and NEST contains a DebugInformation property that provides a human readable description of what happened during the request for both successful and failed requests

var response = client.Search<Project>(s => s
    .Query(q => q
        .MatchAll()
    )
);

response.DebugInformation.Should().Contain("Valid NEST response");

This can be useful in tracking down numerous problems and can also be useful when filing an issue on our github repository.

By default, the request and response bytes are not available within the debug information, but can be enabled globally on Connection Settings

var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));

var settings = new ConnectionSettings(connectionPool)
    .DisableDirectStreaming(); 

var client = new ElasticClient(settings);

disable direct streaming for all requests

or on a per request basis

var response = client.Search<Project>(s => s
    .RequestConfiguration(r => r
        .DisableDirectStreaming() 
    )
    .Query(q => q
        .MatchAll()
    )
);

response.DebugInformation.Should().Contain("\"match_all\":");

disable direct streaming for this request