Channels
Channels handle the mechanics of getting your documents into Elasticsearch reliably: buffering, batching into _bulk requests, concurrent export, retries with backoff, and backpressure -- so you can focus on producing documents and let the channel handle delivery.
IngestChannel<T> is the primary channel type. It uses a composable strategy pattern for all behaviors and auto-configures from ElasticsearchTypeContext when available.
var options = new IngestChannelOptions<Product>(transport, MyContext.Product.Context);
using var channel = new IngestChannel<Product>(options);
await channel.BootstrapElasticsearchAsync(BootstrapMethod.Failure);
channel.TryWrite(new Product { Sku = "ABC", Name = "Widget" });
await channel.WaitForDrainAsync(TimeSpan.FromSeconds(30), ctx);
- Channel configuration: options, buffer configuration, strategies, callbacks
- Legacy channels: migration guide for
DataStreamChannel,IndexChannel,CatalogChannel, and semantic channels
- Create: instantiate with options (and optional
ElasticsearchTypeContextfor auto-configuration) - Bootstrap: call
BootstrapElasticsearchAsyncto create templates and indices - Write: use
TryWrite(non-blocking) orWaitToWriteAsync(with backpressure) to buffer documents - Drain: call
WaitForDrainAsyncto flush all buffered documents - Alias (optional): call
ApplyAliasesAsyncto swap aliases after indexing - Rollover (optional): call
RolloverAsyncto trigger manual index rollover - Dispose: the channel implements
IDisposable
| Method | Behavior |
|---|---|
TryWrite(doc) |
Non-blocking. Returns false if buffer is full. |
WaitToWriteAsync(doc, ctx) |
Async with backpressure. Blocks if buffer is full. |
TryWriteMany(docs) |
Non-blocking batch write. |
WaitToWriteManyAsync(docs, ctx) |
Async batch write with backpressure. |
See push model for details on buffering, batching, and concurrent export.