Example: Creating a custom enrichment manually
You can create a custom enrichment manually by creating and importing a field type that includes the enrichment. In this example, you create custom date and currency converters.
About this task
- You can use the date converter that is provided by default on the
sys.Datefield type to convert a date in the format%Y-%m-%din the US/Eastern time zone to the same format in Coordinated Universal Time (UTC). However, a custom date converter is needed if the date in the document is in a different format or belongs to a different time zone. - Similarly, you can use the currency converter that is provided by default on the
sys.CurrencyCodeObjTypeobject type to convert the seven predefined currency symbols to a required currency code and then check for a match at the start of the value. A custom currency converter is needed if the currency code in the document is different from the pre-defined seven code or if the currency code is present at the end of the text instead of the start.
- Define a JSON file for a new Field Type with the required set of converters or formatters.
- Import the JSON file to create the new Field Type.
- Create a new field, or update an existing field to belong to the Field Type that you imported. From the enrichment settings, choose the new converter or formatter that you defined for the field type.
Instead of creating a new Field Type with just the converter or formatter that is required, it might be useful to extend an existing provided Field Type and re-add all its existing converters, formatter, and validators so that the new Field Type preserves the implementations from the default Field Type. To understand the JSON structure of an existing object type, look at the caDefinitions.json file in the project folder of your downloaded archive.
Procedure
Results
When documents of this type are processed at run time, the value that is extracted for this field is converted to the required date or currency format.
Example
{
"jsonSchemaVer": 3,
"objectTypeList": [
{
"name": "Custom Date",
"symbolicName": "CustomDate",
"description": "Custom Date",
"scope": "custom",
"subtypeOf": "sys.Date",
"cardinality": "single",
"delimiter": "",
"aliasList": [],
"valueFormats": {
"text": {
"extractorSequence": null,
"converterSequence": null,
"formatterSequence": null,
"converterList": [
{
"name": "Date Converter",
"symbolicName": "DateConverter",
"description": "Date Converter",
"tool": "dateconverter",
"format": "%Y-%m-%d",
"timezone": "US/Eastern"
},
{
"name": "Custom Date Converter",
"symbolicName": "CustomDateConverter",
"description": "Custom Date Converter that converts required date seen as - %A, %B %d, %Y at %I:%M:%S %p",
"tool": "dateconverter",
"format": "%A, %B %d, %Y at %I:%M:%S %p",
"timezone": "America/New_York"
}
],
"formatterList": [
{
"name": "Clean up text",
"symbolicName": "TextCleanupFormatter",
"description": "Text Cleanup Formatter",
"tool": "textcleanupformatter"
},
{
"name": "Remove extra spaces",
"symbolicName": "WhitespaceFormatter",
"description": "Remove all extra spaces",
"tool": "whitespaceformatter"
}
]
}
},
"mandatory": false,
"sensitive": false,
"validatorList": [
{
"name": "Datatype Mismatch Validator",
"symbolicName": "DatatypeMismatchValidator",
"description": "Datatype Mismatch Validator",
"tool": "datatypemismatchvalidator",
"severity": "Error",
"failureReason": "Value is not of the supported date format (YYYY-MM-DD)"
},
{
"name": "Low Confidence Validator",
"symbolicName": "LowConfidenceValidator",
"description": "Low Confidence Validator",
"tool": "confidencevalidator",
"threshold": 80,
"severity": "Warning",
"failureReason": "Value confidence lower than the the specified threshold"
},
{
"name": "Required Value Validator",
"symbolicName": "RequiredValueValidator",
"description": "Required Value Validator",
"tool": "requiredvaluevalidator",
"severity": "Error",
"failureReason": "Required value is missing"
},
{
"name": "Near to Current Date Validator",
"symbolicName": "NearToCurrentDateValidator",
"description": "Near To Current Date Validator",
"tool": "neartocurrentdatevalidator",
"numDays": 0,
"condition": ">=",
"severity": "Warning",
"failureReason": "Value should have Number of days (>, >=, <, <=) to the current server date"
},
{
"name": "Date Value Check Validator",
"symbolicName": "DateValueCheckValidator",
"description": "dateValueCheckValidator",
"tool": "datevaluecheckvalidator",
"operator": ">=",
"operand": "1970-01-01",
"severity": "Warning",
"failureReason": "Date should be (==, !=, >, >=, <, <=) to the operand"
},
{
"name": "Date Value Range Validator",
"symbolicName": "DateValueRangeValidator",
"description": "Date Value Range Validator",
"tool": "datevaluerangevalidator",
"minimumDateValue": "1970-01-01",
"maximumDateValue": "9999-12-31",
"severity": "Warning",
"failureReason": "Date should be between the specified minimum and maximum date value"
}
]
},
{
"name": "Custom CurrencyCode Object Type",
"symbolicName": "CustomCurrencyCodeObjType",
"description": "Custom Currency code object type",
"scope": "custom",
"subtypeOf": "sys.CurrencyCodeObjType",
"cardinality": "single",
"delimiter": "",
"aliasList": [],
"valueFormats": {
"text": {
"extractorSequence": null,
"converterSequence": null,
"formatterSequence": null,
"converterList": [
{
"name": "Currency Converter",
"symbolicName": "CurrencyConverter",
"description": "Currency Converter",
"tool": "map",
"wordMap": {
"C$": "CAD",
"Can$": "CAD",
"AU$": "AUD",
"A$": "AUD",
"£": "GBP",
"€": "EUD",
"$": "USD"
},
"positionMatch": "^"
},
{
"name": "Custom Currency Converter",
"symbolicName": "CustomCurrencyConverter",
"description": "Custom Currency Converter that converts code at the start of the value to corresponding symbol.",
"tool": "map",
"wordMap": {
"USD": "$",
"CAD": "Can$",
"AUD": "AU$",
"GBP": "£",
"EUD": "€"
},
"positionMatch": "^"
}
],
"formatterList": [
{
"name": "Remove punctuation",
"symbolicName": "RemovePunctuation",
"description": "Remove Punctuation",
"tool": "regexformatter",
"stringToFind": "'.?!,;:-[]{}()",
"replaceWith": "",
"positionMatch": "*"
},
{
"name": "Clean up text",
"symbolicName": "TextCleanupFormatter",
"description": "Text Cleanup Formatter",
"tool": "textcleanupformatter"
},
{
"name": "Remove extra spaces",
"symbolicName": "WhitespaceFormatter",
"description": "Remove all extra spaces",
"tool": "whitespaceformatter"
}
]
}
},
"mandatory": false,
"sensitive": false,
"validatorList": [
{
"name": "Datatype Mismatch Validator",
"symbolicName": "DatatypeMismatchValidator",
"description": "Datatype Mismatch Validator",
"tool": "datatypemismatchvalidator",
"severity": "Error",
"failureReason": "Value is not a valid 3 letter ISO 4217 standard currency code"
},
{
"name": "Low Confidence Validator",
"symbolicName": "LowConfidenceValidator",
"description": "Low Confidence Validator",
"tool": "confidencevalidator",
"threshold": 80,
"severity": "Warning",
"failureReason": "Value confidence lower than the the specified threshold"
},
{
"name": "Required Value Validator",
"symbolicName": "RequiredValueValidator",
"description": "Required Value Validator",
"tool": "requiredvaluevalidator",
"severity": "Error",
"failureReason": "Required value is missing"
},
{
"name": "Value Length Validator",
"symbolicName": "ValueLengthValidator",
"description": "Value Length Validator",
"tool": "valuelengthvalidator",
"minimumLength": 3,
"maximumLength": 3,
"severity": "Warning",
"failureReason": "Value length should be between the specified minimum and maximum length"
}
]
}
]
}