KeepOnlyTransformer
Retains specified metadata fields and removes all others.
Notes
Keep only the metadata fields provided, delete all other ones. Exact field names (case-insensitive) to keep can be provided as well as a regular expression that matches one or many fields (since 2.1.0).
Note: Unless you have good reasons for doing otherwise, it is recommended to use this handler as one of the last ones to be executed. This is a good practice to ensure all metadata fields are available to other handlers that may require them even if they are not otherwise required.
Can be used both as a pre-parse or post-parse handler.
Examples
The following example keeps only the title and description fields from all extracted fields.
- YAML
- JSON
- XML
handler:
class: ExternalParser
fieldMatcher:
method: REGEX
pattern: title|description
{
"handler": {
"class": "ExternalParser",
"fieldMatcher": {
"method": "REGEX",
"pattern": "title|description"
}
}
}
<handler>
<class>ExternalParser</class>
<fieldMatcher>
<method>REGEX</method>
<pattern>title|description</pattern>
</fieldMatcher>
</handler>
Usage
Full configuration skeleton, with every option and its default
- YAML
- JSON
- XML
class: KeepOnlyTransformer
fieldMatcher:
ignoreCase: false
ignoreDiacritic: false
matchEmpty: false
method: BASIC
negateMatches: false
partial: false
pattern: string
replaceAll: false
trim: false
label: string
{
"class": "KeepOnlyTransformer",
"fieldMatcher": {
"ignoreCase": false,
"ignoreDiacritic": false,
"matchEmpty": false,
"method": "BASIC",
"negateMatches": false,
"partial": false,
"pattern": "string",
"replaceAll": false,
"trim": false
},
"label": "string"
}
<handler>
<class>KeepOnlyTransformer</class>
<fieldMatcher>
<ignoreCase>false</ignoreCase>
<ignoreDiacritic>false</ignoreDiacritic>
<matchEmpty>false</matchEmpty>
<method>BASIC</method>
<negateMatches>false</negateMatches>
<partial>false</partial>
<pattern>string</pattern>
<replaceAll>false</replaceAll>
<trim>false</trim>
</fieldMatcher>
<label>string</label>
</handler>
Properties
| Property | Type | Required | Default |
|---|---|---|---|
fieldMatcher | TextMatcher | No | TextMatcher |
label | string | No | - |
Property Details
fieldMatcher
Matches document fields based on specified patterns and methods
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.