DocumentLengthTransformer
Adds the document length to a specified field
Notes
The length is the document content length as it is in its current processing stage. If for instance you set this transformer after a transformer that modifies the content, the obtained length will be for the modified content, and not the original length. To obtain a document's length before any modification was made to it, use this transformer as one of the first handler in your pre-parse handlers.
Storing values in an existing field
If a document already has a target field with the same name,
new values are appended to the existing list by default. Use onSet to manage this default behavior.
Parser Handler Compatibility
This functionality can be applied as either a pre-parse or post-parse handler.
Examples
The following example stores the document length into a "docSize" field.
- YAML
- JSON
- XML
handler:
class: DocumentLengthTransformer
toField: docSize
{
"handler": {
"class": "DocumentLengthTransformer",
"toField": "docSize"
}
}
<handler>
<class>DocumentLengthTransformer</class>
<toField>docSize</toField>
</handler>
Usage
Full configuration skeleton, with every option and its default
- YAML
- JSON
- XML
class: DocumentLengthTransformer
label: string
onSet: APPEND
toField: string
{
"class": "DocumentLengthTransformer",
"label": "string",
"onSet": "APPEND",
"toField": "string"
}
<handler>
<class>DocumentLengthTransformer</class>
<label>string</label>
<onSet>APPEND</onSet>
<toField>string</toField>
</handler>
Properties
| Property | Type | Required | Default |
|---|---|---|---|
label | string | No | - |
onSet | enum | No | - |
toField | string | No | - |
Property Details
label
An optional, user-supplied label for this step in the importer pipeline. It has no effect on processing — it exists purely to help identify this step, for example in large configurations or in the visual configurator.
onSet
What to do if a target field of the same name already exist.
Allowed Values
APPENDPREPENDREPLACEOPTIONAL
toField
A target field name used to store the value.