GroupDocuments Class
Splits a sequence of documents into groups based on a specified function or metadata key that returns or contains a sequence of group keys.
Namespace
Statiq.Core
Interfaces
Base Types
graph BT Type-->Base0["Module"] click Base0 "/api/Statiq.Common/Module" Base0-->Base1["object"] Type-.->Interface0["IModule"] click Interface0 "/api/Statiq.Common/IModule" Type["GroupDocuments"] class Type type-node

Syntax

public class GroupDocuments : Module, IModule

Remarks

This module forms groups from the input documents. If the function or metadata key returns or contains an enumerable, each item in the enumerable will become one of the grouping keys. If a document contains multiple group keys, it will be included in multiple groups. A good example is a tag engine where each document can contain any number of tags and you want to make groups for each tag including all the documents with that tag. This module outputs a new document with the documents and key for each group.

Constructors

Name Summary
GroupDocuments(Config<IEnumerable<object>>) Partitions the input documents into groups with matching keys based on the key delegate.
GroupDocuments(string) Partitions the result of the input documents into groups with matching keys based on the value(s) at the specified metadata key. If a document to group does not contain the specified metadata key, it is not included in any output groups.

Methods

Name Return Value Summary
AfterExecution(IExecutionContext, ExecutionOutputs) void
Called after each module execution.
Inherited from Module
AfterExecutionAsync(IExecutionContext, ExecutionOutputs) Task
Called after each module execution.
Inherited from Module
BeforeExecution(IExecutionContext) void
Called before each module execution.
Inherited from Module
BeforeExecutionAsync(IExecutionContext) Task
Called before each module execution.
Inherited from Module
ExecuteAsync(IExecutionContext) Task<IEnumerable<IDocument>>
This should not be called directly, instead call IExecutionContext.Execute() if you need to execute a module from within another module.
Inherited from Module
ExecuteContextAsync(IExecutionContext) Task<IEnumerable<IDocument>>
Executes the module once for all input documents.
ExecuteInputAsync(IDocument, IExecutionContext) Task<IEnumerable<IDocument>>
Executes the module.
Inherited from Module
Finally(IExecutionContext) void
Called after each module execution, even if an exception is thrown during execution.
Inherited from Module
FinallyAsync(IExecutionContext) Task
Called after each module execution, even if an exception is thrown during execution.
Inherited from Module
WithComparer(IEqualityComparer<object>) GroupDocuments
Specifies an equality comparer to use for the grouping.
WithComparer<TValue>(IEqualityComparer<TValue>) GroupDocuments
Specifies a typed equality comparer to use for the grouping. A conversion to the comparer type will be attempted for all metadata values. If the conversion fails, the value will not be considered equal. Note that this will also have the effect of treating different convertible types as being of the same type. For example, if you have two group keys, 1 and "1" (in that order), and use a string-based comparison, you will only end up with a single group for those documents with a group key of 1 (since the int key came first).
WithSource(NormalizedPath) GroupDocuments
Sets the source (and destination) of the output document(s).

Extension Methods