Skip to main content

TextBetweenTransformer

Extracts and add values found between a matching start and end strings to a document metadata field

Notes

The matching string end-points are defined in pairs and multiple ones can be specified at once. The field specified for a pair of end-points is considered a multi-value field.

If fieldMatcher is specified, it will use content from matching fields and storing all text extracted into the target field, multi-value. Else, the document content is used.

Storing values in an existing field

If a target field with the same name already exists for a document, values will be added to the end of the existing value list. It is possible to change this default behavior by supplying a PropertySetter.

This class can be used as a pre-parsing handler on text documents only or a post-parsing handler.

Examples

The above example extract the content between OPEN and CLOSE strings, excluding these strings, and store it in a content field.

handler:
class: TextBetweenTransformer
operations:
- toField: content
startMatcher:
pattern: OPEN
endMatcher:
pattern: CLOSE

Usage

Full configuration skeleton, with every option and its default
class: TextBetweenTransformer
label: string
maxReadSize: 0
operations:
- endMatcher: {}
fieldMatcher: {}
inclusive: false
onSet: APPEND
startMatcher: {}
toField: string
sourceCharset: string

Properties

PropertyTypeRequiredDefault
labelstringNo-
maxReadSizeintegerNo10000000
operationsTextBetweenOperation[]No-
sourceCharsetstringNo-

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.

maxReadSize

Max characters to read at once

operations

Allows defining multiple operations as a list.

sourceCharset

Sets the character encoding of the source document to ensure proper reading and processing.