The first step to creating custom comparators is defining the matching logic in custom comparator Java classes that are stored in the real-time module of the Master Index Match Engine. Follow these guidelines when creating the class:
Create a working directory that will contain all the Java packages and the comparators list file for the new comparators.
The Java classes need to implement com.sun.mdm.matcher.comparators.MatchComparator.java interface, located in Matcher.jar. This class includes the methods described below.
Once you create the Java classes, continue to Step 2: Register the Comparator in the Comparators List.
The initialize method initializes the values for the parameters, data sources, and dependency class used for each custom comparator. It provides the necessary information to access the comparator's configuration in the match configuration file and the comparators list file.
void initialize(Map<String, Map> params, Map<String, Map> dataSources, Map<String, Map> dependClassList)
Parameter |
Type |
Description |
---|---|---|
params |
Map |
A mapping of all the parameters associated with a match field in matchConfigFile.cfg. |
dataSources |
Map |
A mapping of all the data sources associated with a match field in matchConfigFile.cfg. |
dependClassList |
Map |
A mapping of all the dependency classes associated with a match field in matchConfigFile.cfg. |
None.
None.
The compareFields method contains all the comparison logic needed to compare two field values and calculate a matching weight that shows how similar the values are.
double compareFields(String recordA, String recordB, Map context)
Parameter |
Type |
Description |
---|---|---|
recordA |
String |
A field value from the record against which the reference record is being compared. |
recordB |
String |
A field value from the reference record. |
context |
Map |
A set of arguments passed to the comparator. |
A number between zero and one that indicates how closely two field values match.
MatchComparatorException
The setRTParameters method sets the runtime parameters for the comparator, providing the ability to customize every call to the parameter.
void setRTParameters(String key, String value)
Parameter |
Type |
Description |
---|---|---|
key |
string |
The key to map the parameter value. |
value |
string |
The value of the parameter. |
None.
None.
The stop method closes any related connections to the data sources used by the comparator.
void stop()
None.
None.
None.