First you have to set this flag
var settings = new ConnectionSettings(connectionPool)
.DisableDirectStreaming();
📓This is for Nest client 6.X
: Debug Information in 6.x
the default is true
/// <summary>
/// Ensures the response bytes are always available on the <see cref="T:Elasticsearch.Net.ElasticsearchResponse`1" /><para>
/// IMPORTANT: Depending on the registered serializer,
/// this may cause the response to be buffered in memory first, potentially affecting performance.
/// </para></summary>
public T DisableDirectStreaming(bool b = true) => this.Assign<bool>(b, (Action<ConnectionConfiguration<T>, bool>) ((a, v) => a._disableDirectStreaming = v));
But for the most current version 8.X
this is a summary:
DisableDirectStreaming When set to true will disable (de)serializing directly to the request and response stream and return a byte[] copy of the raw request and response. Defaults to false.
If you have something like this:
var initialResponse = await _elasticClient.SearchAsync<TResult>
(scr => scr
.From(0)
.Size(scrollSize)
.Type(docTypeName)
.Query(q => query)
.Scroll(scrollTimeout));
in the immediate window (or similar tool) you can call this:
initialResponse.DebugInformation
Or
_elasticClient.RequestResponseSerializer.SerializeToString(query);