Class CountMatchesTransformer
- All Implemented Interfaces:
Configurable<CountMatchesTransformerConfig>,ConfigurableDocHandler<CountMatchesTransformerConfig>,DocHandler
Counts the number of matches of a given string (or string pattern) and store the resulting value in a field in the specified "toField".
If no "fieldMatcher" expression is specified, the document content will be used. If the "fieldMatcher" matches more than one field, the sum of all matches will be stored as a single value. More often than not, you probably want to set your "countMatcher" to "partial".
Storing values in an existing field
If a target field with the same name already exists for a document,
the count value will be added to the end of the existing value list.
It is possible to change this default behavior
with CountMatchesTransformerConfig.setOnSet(PropertySetter).
Can be used as a pre-parse tagger on text document only when matching strings on document content, or both as a pre-parse or post-parse handler when the "fieldMatcher" is used.
- 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
-
CountMatchesTransformer
public CountMatchesTransformer()
-
-
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<CountMatchesTransformerConfig>
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-