Ingest strategies
Ingest strategies control how documents are written to Elasticsearch via the bulk API. They determine the bulk operation header for each document and the target URL.
public interface IDocumentIngestStrategy<in TDocument>
{
BulkAction CreateBulkOperationHeader(TDocument document, string channelHash);
string GetBulkUrl(string defaultPath);
string RefreshTargets { get; }
}
BulkAction is a small struct (Index, Create, Update, Delete, ScriptedHashUpsert, plus WithRequireAlias and WithDynamicTemplates), so returning one per document does not allocate. The BulkOperationHeader classes still work: they convert implicitly to BulkAction.
Writes create operations to a data stream:
{"create": {"_index": "logs-myapp-default"}}
Writes index operations to a named index:
{"index": {"_index": "my-index"}}
Like IndexIngestStrategy but resolves the index name, document ID, and routing from ElasticsearchTypeContext accessors. Supports date-based index naming and hash-based index rotation.
Writes index operations with explicit document IDs for upsert patterns:
{"index": {"_index": "products", "_id": "product-123"}}
Writes to wired streams (managed Elasticsearch Streams ingest). Uses create operations against logs/_bulk, logs.ecs/_bulk, or logs.otel/_bulk depending on WiredStreamIngestEndpoint on the mapping context.