Table of Contents

Class ProjectionRebuildRequest

Namespace
Excalibur.Data.ElasticSearch.Projections
Assembly
Excalibur.Data.ElasticSearch.dll

Represents a request to rebuild a projection.

public sealed class ProjectionRebuildRequest
Inheritance
ProjectionRebuildRequest
Inherited Members

Remarks

Build one through ForIndexMove(Type, string, string) or ForEventRefold<TProjection>() rather than by hand. Each factory states the CHANGE being made, and the Mechanism follows from it; there is no knob that selects a mechanism independently of the data, so the two cannot disagree.

That is deliberate, and it is the point of the pair. A shape change -- a new or renamed field -- cannot be served by copying documents that never carried it, so ForEventRefold<TProjection>() takes no source index: there is no argument in which to name one, and the re-fold binding is not reachable from outside this package. The combination that cannot work therefore has no expression.

Properties

BatchSize

Gets the batch size for processing events during rebuild.

public int BatchSize { get; init; }

Property Value

int

The batch size for processing events during rebuild.

CreateNewIndex

Gets a value indicating whether to create a new index or use an existing one.

public bool CreateNewIndex { get; init; }

Property Value

bool

A value indicating whether to create a new index or use an existing one.

FromTimestamp

Gets the starting point for the rebuild (e.g., event sequence number or timestamp).

public DateTime? FromTimestamp { get; init; }

Property Value

DateTime?

The starting point for the rebuild (e.g., event sequence number or timestamp).

MaxDegreeOfParallelism

Gets the maximum degree of parallelism for the rebuild operation.

public int MaxDegreeOfParallelism { get; init; }

Property Value

int

The maximum degree of parallelism for the rebuild operation.

Mechanism

Gets where this rebuild's destination documents come from.

public ProjectionRebuildMechanism Mechanism { get; }

Property Value

ProjectionRebuildMechanism

EventRefold when the request was built by ForEventRefold<TProjection>(); otherwise IndexCopy.

Remarks

Derived, not stored. There is no setter, so a request cannot claim one mechanism while carrying the other's data.

Metadata

Gets additional metadata for the rebuild operation.

public IDictionary<string, object>? Metadata { get; init; }

Property Value

IDictionary<string, object>

Additional metadata for the rebuild operation.

ProjectionType

Gets the type of projection to rebuild.

public required Type ProjectionType { get; init; }

Property Value

Type

The type of projection to rebuild.

Remarks

The TYPE rather than its name. A projection's store settings live in an options bucket keyed on the FULL type name, and its generation is declared on the type; a simple name carries neither, so a request holding one would resolve an unconfigured bucket and address a different index than the store writes to. No care inside the rebuild can recover a namespace a name has already dropped.

SourceIndexName

Gets the source index an index-to-index rebuild copies from, or null for a re-fold.

public string? SourceIndexName { get; init; }

Property Value

string

The source index an index-to-index rebuild copies from, or null for a re-fold.

TargetIndexName

Gets the target index name for the rebuilt projection.

public required string TargetIndexName { get; init; }

Property Value

string

The target index name for the rebuilt projection.

ToTimestamp

Gets the ending point for the rebuild.

public DateTime? ToTimestamp { get; init; }

Property Value

DateTime?

The ending point for the rebuild.

UseAliasing

Gets a value indicating whether to use index aliasing for zero-downtime rebuilds.

public bool UseAliasing { get; init; }

Property Value

bool

A value indicating whether to use index aliasing for zero-downtime rebuilds.

Methods

ForEventRefold<TProjection>()

Describes a SHAPE CHANGE: the destination documents are re-folded from the event stream, so a new generation may contain fields no stored document has carried.

[RequiresUnreferencedCode("An event re-fold replays through the rebuild service, which serializes the projection type reflectively through IProjectionStore. Use ForIndexMove, which copies documents and does not re-fold, or run the re-fold from a host that permits reflection.")]
[RequiresDynamicCode("An event re-fold replays through the rebuild service, which serializes the projection type reflectively through IProjectionStore. Use ForIndexMove, which copies documents and does not re-fold, or run the re-fold from a host that permits reflection.")]
public static ProjectionRebuildRequest ForEventRefold<TProjection>() where TProjection : class, new()

Returns

ProjectionRebuildRequest

A request whose Mechanism is EventRefold.

Type Parameters

TProjection

The projection whose current handlers produce the new shape.

Remarks

Takes nothing but the projection. There is no source index because a re-fold reads no documents, and no destination index because the re-fold writes through the projection's own store -- so the request cannot name an index that disagrees with where the documents actually land. Index creation and alias swapping are off for the same reason: an empty new index swapped in front of the store's own would hide the documents the re-fold just wrote.

A re-fold replays the whole stream and is slow -- a production replay can run for hours. The operation reports its state as in-progress for that whole duration and reaches completed only once the replay has finished, so a caller can always tell "still folding" from "done".

ForIndexMove(Type, string, string)

Describes a LIKE-FOR-LIKE move: the destination documents are the source documents, copied.

public static ProjectionRebuildRequest ForIndexMove(Type projectionType, string sourceIndexName, string targetIndexName)

Parameters

projectionType Type

The projection type being rebuilt.

sourceIndexName string

The index to copy documents from.

targetIndexName string

The destination index, or the alias to swap onto a new one.

Returns

ProjectionRebuildRequest

A request whose Mechanism is IndexCopy.

Remarks

Use this when the documents do not change shape -- a reshard, a settings change, a move to a new index name. It is far cheaper than a re-fold and remains the right answer for those. It cannot populate a field the source documents lack; use ForEventRefold<TProjection>() for that.