VOOZH about

URL: https://www.nuget.org/packages/Elastic.Transport/

⇱ NuGet Gallery | Elastic.Transport 1.0.0




👁 Image
Elastic.Transport 1.0.0

Prefix Reserved
dotnet add package Elastic.Transport --version 1.0.0
 
 
NuGet\Install-Package Elastic.Transport -Version 1.0.0
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Elastic.Transport" Version="1.0.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Elastic.Transport" Version="1.0.0" />
 
Directory.Packages.props
<PackageReference Include="Elastic.Transport" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Elastic.Transport --version 1.0.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Elastic.Transport, 1.0.0"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Elastic.Transport@1.0.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Elastic.Transport&version=1.0.0
 
Install as a Cake Addin
#tool nuget:?package=Elastic.Transport&version=1.0.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Elastic.Transport

Transport classes and utilities shared among .NET Elastic client libraries. Provides cluster-aware, resilient HTTP transport optimized for the Elastic product suite and Elastic Cloud.

Installation

dotnet add package Elastic.Transport

Quick Start

var settings = new TransportConfiguration(new Uri("http://localhost:9200"));
var transport = new DistributedTransport(settings);

// GET request — returns body as string
var response = transport.Get<StringResponse>("/my-index/_search?q=title:hello");

// POST request — send JSON body
var body = PostData.String(@"{ ""query"": { ""match_all"": {} } }");
var searchResponse = transport.Post<StringResponse>("/my-index/_search", body);

// HEAD request — no body needed
var headResponse = transport.Head("/my-index");

// JSON DOM with safe path traversal
var jsonResponse = transport.Get<JsonResponse>("/my-index/_search?q=title:hello");
int totalHits = jsonResponse.Get<int>("hits.total.value");
string firstId = jsonResponse.Get<string>("hits.hits.[0]._id");

// Async variants
var asyncResponse = await transport.GetAsync<StringResponse>("/my-index/_search?q=title:hello");

Response Types

The generic type parameter on Get<TResponse>, Post<TResponse>, etc. controls how the response body is read:

Type Body Representation Notes
StringResponse string Good for debugging and small payloads
BytesResponse byte[] Raw bytes, useful for binary content
VoidResponse (skipped) Body is not read. Used for HEAD and fire-and-forget calls
StreamResponse Stream Caller must dispose. Best for large payloads
JsonResponse JsonNode System.Text.Json DOM with safe Get<T>() path traversal
DynamicResponse DynamicDictionary Dynamic path traversal via Get<T>()
PipeResponse PipeReader .NET 10+ only. Zero-copy streaming via System.IO.Pipelines

JsonResponse

JsonResponse deserializes JSON into a System.Text.Json.Nodes.JsonNode and exposes a Get<T>() method for safe, typed path traversal using dot-separated keys:

var response = transport.Get<JsonResponse>("/my-index/_search?q=title:hello");

// Traverse nested JSON with dot notation
int totalHits = response.Get<int>("hits.total.value");
string firstId = response.Get<string>("hits.hits.[0]._id");

// Bracket syntax for array access
string lastId = response.Get<string>("hits.hits.[last()]._id");
string firstSource = response.Get<string>("hits.hits.[first()]._source.title");

// _arbitrary_key_ traverses into the first key at that level
string fieldType = response.Get<string>("my-index.mappings.properties._arbitrary_key_.type");

// Direct DOM access is also available via .Body
JsonNode hitsNode = response.Body["hits"]["hits"];

PipeResponse (.NET 10+)

On .NET 10+, PipeResponse exposes the response body as a PipeReader for zero-copy streaming. Pair it with PostData.PipeReader() and PostData.PipeWriter() for efficient request body handling via System.IO.Pipelines.

// Response streaming — deserialize directly from PipeReader
await using var response = await transport.GetAsync<PipeResponse>("/my-index/_search");
var result = await JsonSerializer.DeserializeAsync<SearchResult>(response.Body);

// Request forwarding — pipe an ASP.NET Core request body straight through
var postData = PostData.PipeReader(context.Request.BodyReader);
await using var fwd = await transport.PostAsync<PipeResponse>("/my-index/_doc", postData);
await fwd.CopyToAsync(context.Response.BodyWriter);

See docs/pipe-streaming.md for full API reference and examples.

Configuration

Single node

var settings = new TransportConfiguration(new Uri("http://localhost:9200"));

Elastic Cloud (cloud ID)

var settings = new TransportConfiguration("my-cloud-id", new ApiKey("base64key"));
// or
var settings = new TransportConfiguration("my-cloud-id", new BasicAuthentication("user", "pass"));

Multiple nodes with a node pool

var pool = new StaticNodePool(new[]
{
 new Node(new Uri("http://node1:9200")),
 new Node(new Uri("http://node2:9200")),
 new Node(new Uri("http://node3:9200"))
});
var settings = new TransportConfiguration(pool);
var transport = new DistributedTransport(settings);

All components

var pool = new StaticNodePool(new[] { new Node(new Uri("http://localhost:9200")) });
var requestInvoker = new HttpRequestInvoker();
var product = ElasticsearchProductRegistration.Default;

var settings = new TransportConfiguration(pool, requestInvoker, productRegistration: product);
var transport = new DistributedTransport(settings);

Request Pipeline

The transport models a request pipeline that handles node failover, sniffing, and pinging:

👁 Request Pipeline

The pipeline introduces two special API calls:

  • Sniff — queries the cluster to discover the current node topology
  • Ping — the fastest possible request to check if a node is alive

The transport fails over in constant time. If a node is marked dead, it is skipped immediately (as long as the overall request timeout allows).

Components

Component Description
NodePool Registry of Node instances. Implementations: SingleNodePool, StaticNodePool, SniffingNodePool, StickyNodePool, CloudNodePool
IRequestInvoker Abstraction for HTTP I/O. Default: HttpRequestInvoker
Serializer Request/response serialization. Default uses System.Text.Json
ProductRegistration Product-specific metadata, sniff/ping behavior. Use ElasticsearchProductRegistration for Elasticsearch

Observability

Every response inherits from TransportResponse and exposes an ApiCallDetails property:

var response = transport.Get<StringResponse>("/");

// Structured call metadata
ApiCallDetails details = response.ApiCallDetails;
Console.WriteLine(details.HttpStatusCode);
Console.WriteLine(details.Uri);

// Human-readable debug string
Console.WriteLine(details.DebugInformation);

The transport also emits DiagnosticSource events for serialization timing, time-to-first-byte, and other counters.

Custom Typed Responses

Any class inheriting from TransportResponse can be used as a response type. The transport will deserialize the response body into it using System.Text.Json:

public class SearchResult : TransportResponse
{
 [JsonPropertyName("hits")]
 public HitsContainer Hits { get; set; }
}

public class HitsContainer
{
 [JsonPropertyName("total")]
 public TotalHits Total { get; set; }

 [JsonPropertyName("hits")]
 public List<Hit> Hits { get; set; }
}

public class TotalHits
{
 [JsonPropertyName("value")]
 public long Value { get; set; }
}

public class Hit
{
 [JsonPropertyName("_id")]
 public string Id { get; set; }

 [JsonPropertyName("_source")]
 public JsonNode Source { get; set; }
}

// Use it directly as a type parameter
var response = transport.Get<SearchResult>("/my-index/_search?q=title:hello");
long total = response.Hits.Total.Value;

For full control over how a response is built from the stream, implement TypedResponseBuilder<TResponse> and register it via ResponseBuilders on the configuration:

public class CsvResponse : TransportResponse
{
 public List<string[]> Rows { get; set; }
}

public class CsvResponseBuilder : TypedResponseBuilder<CsvResponse>
{
 protected override CsvResponse Build(ApiCallDetails apiCallDetails, BoundConfiguration boundConfiguration,
 Stream responseStream, string contentType, long contentLength)
 {
 using var reader = new StreamReader(responseStream);
 var rows = new List<string[]>();
 while (reader.ReadLine() is { } line)
 rows.Add(line.Split(','));
 return new CsvResponse { Rows = rows };
 }

 protected override async Task<CsvResponse> BuildAsync(ApiCallDetails apiCallDetails, BoundConfiguration boundConfiguration,
 Stream responseStream, string contentType, long contentLength, CancellationToken cancellationToken = default)
 {
 using var reader = new StreamReader(responseStream);
 var rows = new List<string[]>();
 while (await reader.ReadLineAsync(cancellationToken) is { } line)
 rows.Add(line.Split(','));
 return new CsvResponse { Rows = rows };
 }
}

var settings = new TransportConfiguration(new Uri("http://localhost:9200"))
{
 ResponseBuilders = [new CsvResponseBuilder()]
};

AOT and Source Generators

The default serializer uses System.Text.Json with a JsonSerializerContext for AOT compatibility. When using custom typed responses in AOT/trimmed applications, provide a JsonSerializerContext that includes your response types:

[JsonSerializable(typeof(SearchResult))]
[JsonSerializable(typeof(HitsContainer))]
[JsonSerializable(typeof(TotalHits))]
[JsonSerializable(typeof(Hit))]
public partial class MySerializerContext : JsonSerializerContext;

Create a concrete serializer that combines your context with the transport's built-in resolvers:

public class MySerializer : SystemTextJsonSerializer
{
 public MySerializer() : base(new TransportSerializerOptionsProvider([], null, options =>
 {
 options.TypeInfoResolver = JsonTypeInfoResolver.Combine(
 MySerializerContext.Default,
 new DefaultJsonTypeInfoResolver()
 );
 })) { }
}

var settings = new TransportConfiguration(
 new SingleNodePool(new Uri("http://localhost:9200")),
 serializer: new MySerializer()
);

Links

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 is compatible. 
.NET Framework net461 net461 was computed.  net462 net462 is compatible.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (12)

Showing the top 5 NuGet packages that depend on Elastic.Transport:

Package Downloads
Elastic.Clients.Elasticsearch

This strongly-typed, client library enables working with Elasticsearch. It is the official client maintained and supported by Elastic.

Elastic.Ingest.Transport

Provides components to build a buffer-backed channel for publishing events to distributed systems over HTTP through Elastic.Transport

Elastic.Transport.VirtualizedCluster

Provides a way to assert transport behaviour through a rule engine backed VirtualClusterConnection

Elastic.Ingest

Provides components to build a buffer-backed channel for indexing documents into Elasticsearch

Dnet.Elastic.Clients.Elasticsearch

This strongly-typed, client library enables working with Elasticsearch. It is the official client maintained and supported by Elastic.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Elastic.Transport:

Repository Stars
elastic/elasticsearch-net
This strongly-typed, client library enables working with Elasticsearch. It is the official client maintained and supported by Elastic.
Version Downloads Last Updated
1.0.0 594 6/10/2026
0.17.3 12,497 5/11/2026
0.17.2 268 5/11/2026
0.17.1 253,651 4/28/2026
0.17.0 61,632 4/28/2026
0.16.0 55,432 4/20/2026
0.15.1 838,466 3/11/2026
0.15.0 179,600 2/24/2026
0.14.0 12,021 2/23/2026
0.13.0 724 2/23/2026
0.12.0 2,213 2/20/2026
0.11.1 1,630 2/17/2026
0.11.0 1,589 2/16/2026
0.10.3 549,145 1/22/2026
0.10.2 22,422 12/8/2025
0.10.1 2,777,283 8/19/2025
0.10.0 2,378,638 8/12/2025
0.9.2 1,267,759 5/29/2025
0.9.1 1,832 5/28/2025
0.9.0 1,648 5/28/2025
Loading failed