Class MergeTransformer
- All Implemented Interfaces:
Configurable<MergeTransformerConfig>,ConfigurableDocHandler<MergeTransformerConfig>,DocHandler
Merge multiple metadata fields into a single one.
Use fromFields to list all fields to merge, separated by commas.
Use fromFieldsRegex to match fields to merge using a regular
expression.
Both fromFields and fromFieldsRegex can be used
together. Matching fields from both will be combined, in the order
provided/matched, starting with fromFields entries.
Unless
singleValue is set to true, each value will be
added to the target field, making it a multi-value field. If
singleValue is set to true,
all values will be combined into one string, optionally
separated by the singleValueSeparator. Single values will
be constructed without any separator if none are specified.
You can optionally decide do delete source fields after they were merged
by setting deleteFromFields to true.
The target field can be one of the "from" fields. In such case its
content will be replaced with the result of the merge (it will not be
deleted even if deleteFromFields is true).
If only a single source field is specified or found, it will be copied
to the target field and its multi-values will still be merged to a single one
if configured to do so. In such cases, this class can become an alternative
to using ForceSingleValueTransformer with a "mergeWith" action.
Can be used both as a pre-parse or post-parse handler.
The following merges several title fields into one, joining multiple occurrences with a coma, and deleting original fields.
- See Also:
-
Field Summary
Fields inherited from interface com.norconex.commons.lang.config.Configurable
PROPERTYFields inherited from interface com.norconex.importer.handler.DocHandler
NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleanbooleanhandle(DocHandlerContext docCtx) Perform any operations on a document.inthashCode()toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.norconex.importer.handler.DocHandler
close, init
-
Constructor Details
-
MergeTransformer
public MergeTransformer()
-
-
Method Details
-
handle
Description copied from interface:DocHandlerPerform any operations on a document.- Specified by:
handlein interfaceDocHandler- Parameters:
docCtx- the document handling context- Returns:
falseto stop processing and reject a document ortrueto proceed to the next configured handler.- Throws:
IOException- An I/O exception of some sort has occurred
-
getConfiguration
- Specified by:
getConfigurationin interfaceConfigurable<MergeTransformerConfig>
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-