NAV Navbar
Python Java C G2Command shell

Introduction

Welcome to the Senzing API reference. The APIs allow you to embed and leverage Senzing's world-class Entity Resolution capabilities into your applications, solutions and systems.

If you're new to Senzing and Entity Resolution be sure to check out basic information on Senzing and our technology. Before you go any further and if you haven't already, register for the knowledge center this provides access to information, articles, FAQs, etc. Links herein refer to the knowledge center; you really should register!

System Requirements

Current requirements for deploying G2 and utilizing the APIs can be found at System Requirements.

Messaging Format

The G2 APIs currently accept request messages and return response messages in JSON format. The JSON format and terms understood by G2 are outlined in the Generic Entity Specification.

APIs that accept a file as input expect the file to also be JSON adhering to the Generic Entity Specification.

Arguments

Many of the APIs accept one or more arguments, some of which are required and others optional. Required arguments are indicated with surrounding <...> and optional arguments with [...]

Arguments are documented with their respective API information.

Quickstart

G2Command Quickstart Tutorial

For a quickstart tutorial on the G2Command shell, visit our G2Command Quickstart Tutorial.

Interpreting Entity API Response Messages

For a quickstart tutorial on interpreting entity API response messages, visit the Interpreting Entity API Response Messages tutorial

G2Engine

Initialization Parameters

The G2 Engine uses a set of initialization parameters to start up the engine. These may be specified in either a JSON document, or included in an INI file.

The original initialization functions accept the INI file as input argument. These, however, are now deprecated.

The version-2 initialization functions (which include "V2" in the function names), require the JSON document of system parameters.

Sample parameter JSON document:

{
    "PIPELINE": {
        "SUPPORTPATH": "/opt/senzing/g2/data"
    },
    "SQL": {
        "CONNECTION": "sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db",
        "G2CONFIGFILE": "/opt/senzing/g2/python/g2config.json"
    }
}

Sample parameter INI file ("G2Module.ini"):

[PIPELINE]
  SUPPORTPATH=/opt/senzing/g2/data
[SQL]
  CONNECTION=sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db
  G2CONFIGFILE=/opt/senzing/g2/python/g2config.json

Engine Control Flags

The G2 Engine has many functions whose behavior or output can be customized by control flags. These flag values are defined here.

The flags here may be combined through a "logical-or" operation to form a bitmask containing several flag values. The flag bitmask values are them passed into the various functions that accept them.

Entity Export

These flags are used to specify what kind of entities/relationships to include in exports.

Flag Meaning
G2_EXPORT_INCLUDE_ALL_ENTITIES Include all the entities in the export
G2_EXPORT_CSV_INCLUDE_FULL_DETAILS Include full details on a CSV export
G2_EXPORT_INCLUDE_RESOLVED Include resolved entity matches (Match Level 1)
G2_EXPORT_INCLUDE_POSSIBLY_SAME Include possibly the same entity matches (Match Level 2)
G2_EXPORT_INCLUDE_POSSIBLY_RELATED Include possibly related entity matches (Match Level 3)
G2_EXPORT_INCLUDE_NAME_ONLY Internal only use at this time
G2_EXPORT_INCLUDE_DISCLOSED Include disclosed relationship entity matches

Entity Features

These flags indicate what features should be returned as part of entity data

Flag Meaning
G2_ENTITY_INCLUDE_ALL_FEATURES Include all features for the entity
G2_ENTITY_INCLUDE_REPRESENTATIVE_FEATURES Include a set of representative features, rather than every feature
G2_ENTITY_INCLUDE_SINGLE_FEATURES Include a single feature of each feature type
G2_ENTITY_INCLUDE_NO_FEATURES Do not include features

Finding Entity Paths

These flags indicate how entity paths should be computed

Flag Meaning
G2_FIND_PATH_PREFER_EXCLUDE Exclude the forbidden entities if possible, but use them if necessary.

Entity Relationships

These flags indicate what relationships should be returned as part of entity data

Flag Meaning
G2_ENTITY_INCLUDE_ALL_RELATIONS Include all relations for an entity
G2_ENTITY_INCLUDE_POSSIBLY_SAME_RELATIONS Include possibly the same entity matches (Match Level 2)
G2_ENTITY_INCLUDE_POSSIBLY_RELATED_RELATIONS Include possibly related entity matches (Match Level 3)
G2_ENTITY_INCLUDE_NAME_ONLY_RELATIONS Internal only use at this time
G2_ENTITY_INCLUDE_DISCLOSED_RELATIONS Include disclosed relationship entity matches
G2_ENTITY_INCLUDE_NO_RELATIONS Do not include relations

Further Reducing Entity Data

These flags are also used to reduce how much data should be returned as part of entity data.

Flag Meaning
G2_ENTITY_MINIMAL_FORMAT Get only the minimal data for entities/relationships
G2_SEARCH_NO_FEATURE_SCORES Exclude feature scores from search results

These flag mask values indicate the recommended settings for various operations

Flag Combination Meaning
G2_EXPORT_DEFAULT_FLAGS Used for exporting entities
G2_ENTITY_DEFAULT_FLAGS Used for displaying entity data
G2_FIND_PATH_DEFAULT_FLAGS Used for finding entity paths
G2_SEARCH_BY_ATTRIBUTES_DEFAULT_FLAGS Recommended settings for searching-by-attribute calls
G2_SEARCH_BY_ATTRIBUTES_MINIMAL_STRONG Searches will return minimal data with only the strongest matches
G2_SEARCH_BY_ATTRIBUTES_MINIMAL_ALL Searches will return minimal data with all matches

Deprecated Values

Flag Meaning
G2_EXPORT_DEFAULT_REPORT_FLAGS An older version of G2_EXPORT_DEFAULT_FLAGS

Engine

Initialization

Example code:

from G2Engine import G2Engine

#----------------------------------------
if __name__ == '__main__':
    moduleName = "pyG2"
    iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}"
    verboseLogging = False

    # Create the G2Engine object with the G2Module.ini once per process
    engine = G2Engine()

    # Initialize the G2Engine once per process. This will take a few seconds.
    initRet = engine.initV2(moduleName, iniParams, verboseLogging)

    # (alternatively, initialize the G2Engine with a specific config ID)
    engine.destroy()
    initConfigID = 1234
    initWithConfigRet = engine.initWithConfigIDV2(moduleName, iniParams, initConfigID, verboseLogging)

    # Reinitialize the G2Engine process, using a different configuration ID.
    reinitConfigID = 5678
    reinitRet = engine.reinitV2(reinitConfigID)
import com.senzing.g2.engine.G2Engine;
import com.senzing.g2.engine.G2JNI;
import com.senzing.g2.engine.Result;

//...

    String moduleName = "G2JNI";
    String iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}";
    boolean verboseLogging = false;

/** init */
    G2Engine engine = new G2JNI();
    int initResult = engine.initV2(moduleName, iniParams, verboseLogging);

/** alternativiely, inititialize with a specific configuration ID */
    engine.destroy();
    int initConfigID = 1234;
    int initResult = engine.initWithConfigIDV2(moduleName, iniParams, initConfigID, verboseLogging);

/** reinitialize the G2Engine process, using a different configuration ID. */
    int reinitConfigID = 5678;
    int initResult = engine.reinitV2(reinitConfigID);

#include "libg2.h"
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argsz[])
{
    char *moduleName = "g2module";
    char *iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}";
    bool verboseLogging = false;

    // Initialize the G2Engine once per process
    int ret = G2_init_V2(moduleName, iniParams, verboseLogging);

    // (alternatively, initialize the G2Engine with a specific config ID)
    G2_destroy();
    long long initConfigID = 1234;
    int initWithConfigRet = G2_initWithConfigID_V2(moduleName, iniParams, initConfigID, verboseLogging);

    // Reinitialize the G2Engine process, using a different configuration ID.
    long long reinitConfigID = 5678;
    int reinitRet = G2_reinit_V2(reinitConfigID);
}
cd /opt/senzing/g2/python
python G2Command.py

To start using the Senzing engine, you must first create and initialize an instance of the engine. This should be done once per process.

Create a new instance of the Senzing engine and assign it to a variable. Then, call the appropriate initialization method (such as initV2) to initialize the engine.

The init and initAndGetConfigID functions are deprecated. The version-2 functions (such as initV2) should be used instead.

During the call, the initialization methods accept the following parameters:

Calling these functions will return "0" upon success - useful for error handling.

There is also a reinitV2 function, which may be used to reinitialize the engine using a specified initConfigID.

Prime Engine

Example code:

     #primeEngine
     ret = engine.primeEngine()
/** primeEngine */
    int ret = engine.primeEngine();
    //primeEngine
    int ret = G2_primeEngine();
(g2) primeEngine

The primeEngine() method may optionally be called to pre-initialize some of the heavier weight internal resources of the G2 engine.

Uninitialization

Example code:

   # When done with all G2 requests in the process, shutdown the G2Engine
   engine.destroy()
/** destroy */
    int destroyResult = engine.destroy();

    int ret = G2_destroy();
(g2) quit
Ending Terminal.

(g2) exit
Ending Terminal.

(g2) <CTRL-C>

Are you sure you want to exit?  yes
^C

Once all searching is done in a given process, call destroy() to uninitialize Senzing and clean up resources. You should always do this once at the end of each process.

Statistics

Example code:

     #Retrieve stats
     ret = engine.stats()
     print ret
/** stats */
    String stats = engine.stats();

    System.out.println("STATS: " + stats);
    char *response = NULL;
    size_t bufSize = 0;

    //stats
    int ret = G2_stats(&response,&bufSize,realloc);
    printf("STATS: %s\n", response);
    free(response);
(g2) stats

Example response:

{"workload": {"suppressedScoredFeatureType": [], "busyWait": 0, "ambiguousTest": 0, "scoredPairs": [{"ADDRESS": 1}, {"DOB": 1}, {"NAME": 1}], "grouperKeyMatch": 0, "duration": 0, "delete records": 0, "latchContention": [], "longBusyWait": 0, "cacheMiss": [{"ADDRESS": 1}, {"DOB": 1}, {"NAME": 1}], "abortedUnresolve": 0, "cacheHit": [], "candidates": 0, "unresolveTriggers": {"prune": 0, "ambiguousMultiResolve": 0, "update": 0, "normalResolve": 0, "relLink": 0, "ambiguousNoResolve": 0, "extensiveResolve": 0}, "reducedScoredFeatureType": [], "records": 1, "unresolveTest": 0, "genericDetect": [], "redoTriggers": [], "suppressedCandidateBuilders": [], "retries": 0, "gnrScorersUsed": 1, "candidateBuilders": [], "loadedRecords": 0}}

Call stats() to retrieve workload statistics for the current process. These statistics will automatically reset after retrieval.

(Note: when using C, the stats() method accepts the following three parameters as input:

Export Config

Example code:

    response = bytearray("")
    configID = bytearray([])

    #exportConfig
    ret = engine.exportConfig(response, configID)

    print str(response)

    StringBuffer response = new StringBuffer();

/** exportConfig */
    int ret = engine.exportConfig(response);
    System.out.println("CONFIG: " + response.toString());

/** exportConfigAndConfigID */
    Result<Long> configID = new Result<Long>();
    int ret = engine.exportConfig(response, configID);
    System.out.println("CONFIG: " + response.toString());

    char *response = NULL;
    size_t bufSize = 0;

    //exportConfig
    int ret = G2_exportConfig(&response,&bufSize,realloc);
    printf("EXPORT CONFIG: %s\n", response);
    free(response);

    //exportConfigAndConfigID
    response = NULL;
    long long configID;
    int ret = G2_exportConfigAndConfigID(&response, &bufSize, realloc, &configID);
    printf("CONFIG ID: %lld\n", configID);

(g2) exportConfig

Example response is really, really long...

Call exportConfig to retrieve your Senzing engine's configuration. The call will assign a JSON document to a user-designated buffer, containing all relevant configuration information -- the function itself will return "0" upon success. The exportConfig function accepts the following parameters as input:

Active ConfigID

Example code:

   # Get active configID
   configID = bytearray([])
   ret = engine.getActiveConfigID(configID)

   print("Active configID: " + str(configID))

    Result<Long> configID = new Result<Long>();

/** getActiveConfigID */
    int ret = engine.getActiveConfigID(configID);

    System.out.println("Active configID: " + configID.getValue());

    long long configID;

    //getActiveConfigID
    int ret = G2_getActiveConfigID(&configID);
    printf("Active configID: %lld\n", configID);

(g2) getActiveConfigID

Example response:

Active configID: 113127798

Call getActiveConfigID() to return an identifier for the loaded Senzing engine configuration. The call will assign a long integer to a user-designated variable -- the function itself will return "0" upon success. The getActiveConfigID() method accepts one parameter as input:

Repository's Last Modified Time

Example code:

   # Get repository's last modified time
   lastModifiedTime = bytearray([])
   ret = engine.getRepositoryLastModifiedTime(lastModifiedTime)

   print("Last modified time: " + str(lastModifiedTime))

    Result<Long> lastModifiedTime = new Result<Long>();

/** getRepositoryLastModifiedTime */
    int ret = engine.getRepositoryLastModifiedTime(lastModifiedTime);

    System.out.println("Last modified time: " + lastModifiedTime.getValue());

    long long lastModifiedTime;

    //getRepositoryLastModifiedTime
    int ret = G2_getRepositoryLastModifiedTime(&lastModifiedTime);
    printf("Last modified time: %lld\n", lastModifiedTime);
(g2) getRepositoryLastModifiedTime

Example response:

Last modified time: 1530887677083

Call getRepositoryLastModifiedTime() to obtain the last modified time of the Senzing repository, measured in the number of seconds between the last modified time and January 1, 1970 12:00am GMT (epoch time). The call will assign a long integer to a user-designated buffer -- the function itself will return "0" upon success. The getRepositoryLastModifiedTime() method accepts one parameter as input:

Data Manipulation

Entity data can be easily loaded into the data repository through the use of the G2 interface. This allows for a more direct way of adding (or removing) data from an application system.

There is much background on the core of the JSON messages in the Generic Entity Specification article. This information can help to create the necessary JSON documents for specifying entity attributes.

With a few function calls, you can manipulate data using a few key fields and a simple JSON document outlining the entity attributes.

Adding Records

Example code:

    dataSourceCode = 'TEST'
    recordID = 'entity_record_id'
    jsonData = '{"NAMES": [{ "NAME_TYPE": "PRIMARY", "NAME_LAST": "Smith", "NAME_FIRST": "John", "NAME_MIDDLE": "M"}], "PASSPORT_NUMBER": "PP11111", "PASSPORT_COUNTRY": "US", "DRIVERS_LICENSE_NUMBER": "DL11111", "SSN_NUMBER": "111-11-1111" }'
    loadID = None

    # Add data record(s)
    # Make as many parallel requests as desired.
    ret = engine.addRecord(dataSourceCode,recordID,jsonData,loadID)

    # addRecordWithRecordID
    recordID2 = bytearray("")
    ret = engine.addRecordWithReturnedRecordID(dataSourceCode,recordID2,jsonData,loadID)

    print("New Record ID: "+str(recordID2))

    # addRecordWithInfo
    responseBuffer = bytearray("")
    flags = 0
    ret = engine.addRecordWithInfo(dataSourceCode, recordID, jsonData, responseBuffer, loadID, flags)
    print("Modified Entities: "+str(responseBuffer))

    String dataSourceCode = "TEST";
    String recordID = "RECORD3";
    String jsonData =  "{\"NAME_TYPE\": \"PRIMARY\", \"NAME_FIRST\": \"JANE\", \"NAME_LAST\": \"SMITH\", \"ADDR_TYPE\": \"HOME\", \"ADDR_LINE1\": \"653 STATE ROUTE 7\", \"ADDR_CITY\": \"FRESNO\", \"ADDR_STATE\": \"CA\", \"ADDR_POSTAL_CODE\": \"55073-1234\"}";
    String loadID = null;

/** addRecord */
    int ret = engine.addRecord(dataSourceCode, recordID, jsonData, loadID);

/** addRecordWithReturnedRecordID */
    StringBuffer recordID2 = new StringBuffer();
    int ret2 = engine.addRecordWithReturnedRecordID(dataSourceCode, recordID2, jsonData, loadID);

    System.out.println("New Record ID: " + recordID2.toString());

/** addRecordWithInfo */
    StringBuffer responseBuffer = new StringBuffer();
    int flags = 0;
    int ret3 = engine.addRecordWithInfo(dataSourceCode, recordID, jsonData, loadID, flags, responseBuffer);

    System.out.println("Modified Entities: " + responseBuffer.toString());

    const char *dataSourceCode = "TEST";
    const char *recordID = "RECORD3";
    const char *jsonData =  "{\"NAME_TYPE\": \"PRIMARY\", \"NAME_FIRST\": \"JANE\", \"NAME_LAST\": \"SMITH\", \"ADDR_TYPE\": \"HOME\", \"ADDR_LINE1\": \"653 STATE ROUTE 7\", \"ADDR_CITY\": \"FRESNO\", \"ADDR_STATE\": \"CA\", \"ADDR_POSTAL_CODE\": \"55073-1234\"}";
    const char *loadID = NULL;

    //Add record
    int ret = G2_addRecord(dataSourceCode, recordID, jsonData, loadID);

    char recordID2[64*1028];

    //Add record with returned id
    int ret2 = G2_addRecordWithReturnedRecordID(dataSourceCode, jsonData, loadID, recordID2, sizeof(response));
    printf("New Record ID: %s\n", recordID2);

    // Add record with info
    int bufferSize = 64*1028;
    char* responseBuffer = new char[bufferSize];
    int flags = 0;
    int ret3 = G2_addRecordWithInfo(dataSourceCode, recordID, jsonData, loadID, flags, &responseBuffer, &bufferSize, realloc);
    printf("Modified Entities: %s\n", responseBuffer);

(g2) addRecord TEST RECORD3 "{\"NAME_TYPE\": \"PRIMARY\", \"NAME_FIRST\": \"JANE\", \"NAME_LAST\": \"SMITH\", \"ADDR_TYPE\": \"HOME\", \"ADDR_LINE1\": \"653 STATE ROUTE 7\", \"ADDR_CITY\": \"FRESNO\", \"ADDR_STATE\": \"CA\", \"ADDR_POSTAL_CODE\": \"55073-1234\"}"
(g2) addRecordWithInfo TEST RECORD3 "{\"NAME_TYPE\": \"PRIMARY\", \"NAME_FIRST\": \"JANE\", \"NAME_LAST\": \"SMITH\", \"ADDR_TYPE\": \"HOME\", \"ADDR_LINE1\": \"653 STATE ROUTE 7\", \"ADDR_CITY\": \"FRESNO\", \"ADDR_STATE\": \"CA\", \"ADDR_POSTAL_CODE\": \"55073-1234\"}"

Example response:

New Record ID: 49AD3C65923BFAC7275ACB06019131E353B0373C

Modified Entities: {"DATA_SOURCE":"TEST","RECORD_ID":"RECORD3","AFFECTED_ENTITIES":[{"ENTITY_ID":1,"LENS_CODE":"DEFAULT"}]}

Once the Senzing engine is initialized, use addRecord() to load a record into the Senzing repository -- addRecord() can be called as many times as desired and from multiple threads at the same time. The addRecord() function returns "0" upon success, and accepts four parameters as input:

Relatedly, the addRecordWithReturnedRecordID() method behaves identically to addRecord(), with the single difference that the user does not pre-specify the record ID of the added record. Rather, addRecordWithReturnedRecordID() generates a new, unique record ID for the record loaded into the Senzing repository. In particular, addRecordWithReturnedRecordID() accepts the following parameters as input:

addRecordWithInfo() is available if you would like to know what resolved entities were modified when adding the new record. It behaves identically to addRecord(), but returns a json document containing the IDs of the affected entities. It accepts the following parameters:

Deleting Records

Example code:

    dataSourceCode = 'TEST'
    recordID = 'entity_record_id'
    loadID = None

    # deleteRecord
    ret = engine.deleteRecord(dataSourceCode,recordID,loadID)

    # deleteRecordWithInfo
    responseBuffer = bytearray("")
    flags = 0
    ret2 = engine.deleteRecordWithInfo(dataSourceCode, recordID, responseBuffer, loadID, flags)
    print("Modified Entities: "+str(responseBuffer))

    String dataSourceCode = "TEST";
    String recordID = "RECORD3";
    String loadID = null;

/** deleteRecord */
    int ret = engine.deleteRecord(dataSourceCode, recordID, loadID);

/** deleteRecordWithInfo */
    StringBuffer responseBuffer = new StringBuffer();
    int flags = 0;
    int ret2 = engine.deleteRecordWithInfo(dataSourceCode, recordID, loadID, flags, responseBuffer)
    System.out.println("Modified Entities: " + responseBuffer.toString());

    const char *dataSourceCode = "TEST";
    const char *recordID = "RECORD3";
    const char *loadID = NULL;

    //Delete record
    int ret = G2_deleteRecord(dataSourceCode, recordID, loadID);

    //Delete record with info
    int bufferSize = 64*1028;
    char* responseBuffer = new char[bufferSize];
    int flags = 0;
    int ret2 = G2_deleteRecordWithInfo(dataSourceCode, recordID, loadID, flags, &responseBuffer, &bufferSize, realloc)
    printf("Modified Entities: %s\n", responseBuffer);

(g2) deleteRecord TEST RECORD3
(g2) deleteRecordWithInfo TEST RECORD3

Example response:

Modified Entities: {"DATA_SOURCE":"TEST","RECORD_ID":"entity_record_id","AFFECTED_ENTITIES":[{"ENTITY_ID":1,"LENS_CODE":"DEFAULT"}]}

Similarly, use deleteRecord() to remove a record from the data repository (returns "0" upon success) ; deleteRecord() can be called as many times as desired and from multiple threads at the same time. The deleteRecord() function accepts three parameters as input:

deleteRecordWithInfo() behaves the same as deleteRecord() but also returns a json document containing the IDs of the affected entities. It accepts the following parameters:

Replacing Records

Example code:

    dataSourceCode = 'TEST'
    recordID = 'entity_record_id'
    jsonData = '{"NAMES": [{ "NAME_TYPE": "PRIMARY", "NAME_LAST": "Smith", "NAME_FIRST": "John", "NAME_MIDDLE": "M"}], "PASSPORT_NUMBER": "PP11111", "PASSPORT_COUNTRY": "US", "DRIVERS_LICENSE_NUMBER": "DL11111", "SSN_NUMBER": "111-11-1111" }'
    loadID = None

    #replaceRecord
    ret = engine.replaceRecord(dataSourceCode,recordID,jsonData,loadID)

    # replaceRecordWithInfo
    responseBuffer = bytearray("")
    flags = 0
    ret = engine.replaceRecordWithInfo(dataSourceCode, recordID, jsonData, responseBuffer, loadID, flags)
    print("Modified Entities: "+str(responseBuffer))

    String dataSourceCode = "TEST";
    String recordID = "RECORD3";
    String jsonData =  "{\"NAME_TYPE\": \"PRIMARY\", \"NAME_FIRST\": \"JANE\", \"NAME_LAST\": \"SMITH\", \"ADDR_TYPE\": \"HOME\", \"ADDR_LINE1\": \"653 STATE ROUTE 7\", \"ADDR_CITY\": \"FRESNO\", \"ADDR_STATE\": \"CA\", \"ADDR_POSTAL_CODE\": \"55073-1234\"}";
    String loadID = null;

/** replaceRecord */
    int ret = engine.replaceRecord(dataSourceCode, recordID, jsonData, loadID);

/** replaceRecordWithInfo */
    StringBuffer responseBuffer = new StringBuffer();
    int flags = 0;
    int ret2 = engine.replaceRecordWithInfo(dataSourceCode, recordID, jsonData, loadID, flags, responseBuffer);

    System.out.println("Modified Entities: " + responseBuffer.toString());

    const char *dataSourceCode = "TEST";
    const char *recordID = "RECORD3";
    const char *jsonData =  "{\"NAME_TYPE\": \"PRIMARY\", \"NAME_FIRST\": \"JANE\", \"NAME_LAST\": \"SMITH\", \"ADDR_TYPE\": \"HOME\", \"ADDR_LINE1\": \"653 STATE ROUTE 7\", \"ADDR_CITY\": \"FRESNO\", \"ADDR_STATE\": \"CA\", \"ADDR_POSTAL_CODE\": \"55073-1234\"}";
    const char *loadID = NULL;

    //Replace record
    int ret = G2_replaceRecord(dataSourceCode, recordID, jsonData, loadID);

    //Replace record with info
    int bufferSize = 64*1028;
    char* responseBuffer = new char[bufferSize];
    int flags = 0;
    int ret3 = G2_addRecordWithInfo(dataSourceCode, recordID, jsonData, loadID, flags, &responseBuffer, &bufferSize, realloc);
    printf("Modified Entities: %s\n", responseBuffer);

(g2) replaceRecord TEST RECORD3 "{\"NAME_TYPE\": \"PRIMARY\", \"NAME_FIRST\": \"JANE\", \"NAME_LAST\": \"SMITH\", \"ADDR_TYPE\": \"HOME\", \"ADDR_LINE1\": \"653 STATE ROUTE 7\", \"ADDR_CITY\": \"FRESNO\", \"ADDR_STATE\": \"CA\", \"ADDR_POSTAL_CODE\": \"55073-1234\"}"
(g2) replaceRecordWithInfo TEST RECORD3 "{\"NAME_TYPE\": \"PRIMARY\", \"NAME_FIRST\": \"JANE\", \"NAME_LAST\": \"SMITH\", \"ADDR_TYPE\": \"HOME\", \"ADDR_LINE1\": \"653 STATE ROUTE 7\", \"ADDR_CITY\": \"FRESNO\", \"ADDR_STATE\": \"CA\", \"ADDR_POSTAL_CODE\": \"55073-1234\"}"

Example response:

Modified Entities: {"DATA_SOURCE":"TEST","RECORD_ID":"entity_record_id","AFFECTED_ENTITIES":[{"ENTITY_ID":1,"LENS_CODE":"DEFAULT"}]}

Use the replaceRecord() function to update or replace a record in the data repository (if record doesn't exist, a new record is added to the data repository). Like the above functions, replaceRecord() returns "0" upon success, and it can be called as many times as desired and from multiple threads at the same time. The replaceRecord() function accepts four parameters as input:

replaceRecordWithInfo() is available if you would like to know what resolved entities were modified when replacing a record. It behaves identically to replaceRecord(), but also returns a json document containing the IDs of the affected entities. It accepts the following parameters:

Loading data and exporting is the core use case for batch style Entity Resolution but, when it comes to interactive use of Entity Resolution intelligence, search is a key component. The core Senzing engine provides real-time search capabilities that are easily accessed via the available G2Engine.py interface.

There is much background on the core of the JSON messages in the Generic Entity Specification article.

Retrieve a Record

Example code:

    dataSourceCode = 'TEST'
    recordID = 'entity_record_id'
    response = bytearray("")


    # getRecord
    ret = engine.getRecordV2(dataSourceCode,recordID,engine.G2_ENTITY_DEFAULT_FLAGS,response)
    print str(response)

    String dataSourceCode = "TEST";
    String recordID = "RECORD3";
    StringBuffer response = new StringBuffer();

/** getRecord */
    int ret = engine.getRecordV2(dataSourceCode, recordID, G2Engine.G2_ENTITY_DEFAULT_FLAGS, response);

    System.out.println("GET RECORD: " + response.toString());
    System.out.println("");

    const char *dataSourceCode = "TEST";
    const char *recordID = "RECORD3";
    char *response = NULL;
    size_t bufSize = 0;

    //Get record
    int ret = G2_getRecord_V2(dataSourceCode, recordID, G2_ENTITY_DEFAULT_FLAGS, &response, &bufSize, realloc);
    printf("RECORD: %s\n", response);
    free(response);


(g2) getRecordV2 TEST RECORD3 4352

Example output:

{
    "JSON_DATA": {
        "NAMES": [{
            "NAME_TYPE": "PRIMARY",
            "NAME_LAST": "Smith",
            "NAME_FIRST": "John",
            "NAME_MIDDLE": "M"
        }],
        "PASSPORT_NUMBER": "PP11111",
        "PASSPORT_COUNTRY": "US",
        "DRIVERS_LICENSE_NUMBER": "DL11111",
        "SSN_NUMBER": "111-11-1111",
        "DATA_SOURCE": "TEST",
        "ENTITY_TYPE": "TEST",
        "DSRC_ACTION": "A",
        "LENS_CODE": "DEFAULT",
        "RECORD_ID": "RECORD3"
    },
    "NAME_DATA": ["PRIMARY: Smith John M"],
    "ATTRIBUTE_DATA": [],
    "IDENTIFIER_DATA": ["DRLIC: DL11111","PASSPORT: PP11111 US","SSN: 111-11-1111"],
    "ADDRESS_DATA": [],
    "PHONE_DATA": [],
    "RELATIONSHIP_DATA": [],
    "ENTITY_DATA": [],
    "OTHER_DATA": [],
    "DATA_SOURCE": "TEST",
    "RECORD_ID": "RECORD3",
    "ENTITY_TYPE": "TEST",
    "ENTITY_KEY": "DC22202DD6CC5FFF711D866BCF1394489FFA9180",
    "OBS_ENT_HASH": "DC22202DD6CC5FFF711D866BCF1394489FFA9180",
    "LAST_SEEN_DT": "2019-03-01 00:40:17.583"
}

Use getRecordV2() to retrieve a single record from the data repository; the record is assigned in JSON form to a user-designated buffer, and the function itself returns "0" upon success. Once the Senzing engine is initialized, getRecordV2() can be called as many times as desired and from multiple threads at the same time. The getRecordV2() function accepts the following parameters as input:

The function getRecordV2() is an improved version of getRecord() that also allows you to use control flags. The getRecord() function has been deprecated.

Example code:

    dataSourceCode = 'TEST'
    recordID = 'entity_record_id'
    loadID = None

    #...

    entityID = 1
    response = bytearray("")

    #getEntityByEntityID
    ret2 = engine.getEntityByEntityIDV2(entityID,engine.G2_ENTITY_DEFAULT_FLAGS,response)
    print str(response)

    #...

    response = bytearray("")

    #getEntityByRecordID
    ret3 = engine.getEntityByRecordIDV2(dataSourceCode,recordID,engine.G2_ENTITY_DEFAULT_FLAGS,response)
    print str(response)

    String dataSourceCode = "TEST";
    String recordID = "RECORD3";

//...

    long entityID = 1;
    StringBuffer response = new StringBuffer();

/** getEntityByEntityID */
    int ret2 = engine.getEntityByEntityIDV2(entityID, G2Engine.G2_ENTITY_DEFAULT_FLAGS, response);
    System.out.println("GET Entity: " + response.toString());

//...

    response = new StringBuffer();

/** getEntityByRecordID */
    int ret3 = engine.getEntityByRecordIDV2(dataSourceCode,recordID,G2Engine.G2_ENTITY_DEFAULT_FLAGS,response);
    System.out.println("GET Entity: " + response.toString());
    const char *dataSourceCode = "TEST";
    const char *recordID = "RECORD3";

    char *response = NULL;
    size_t bufSize = 0;
    const long long entityID = 4001;

    //Get entity by entityID
    int ret1 = G2_getEntityByEntityID_V2(entityID, G2_ENTITY_DEFAULT_FLAGS, &response, &bufSize, realloc);
    printf("ENTITY: %s\n", response);
    free(response);

    response = NULL;

    //Get entity by recordID
    int ret2 = G2_getEntityByRecordID_V2(dataSourceCode,recordID,G2_ENTITY_DEFAULT_FLAGS,&response, &bufSize,realloc);
    printf("ENTITY: %s\n", response);
    free(response);
(g2) getEntityByEntityIDV2 1 4352

(g2) getEntityByRecordIDV2 TEST entity_record_id 4352

Example return:

{
    "RESOLVED_ENTITY": {
        "ENTITY_ID": 1,
        "LENS_ID": 1,
        "ENTITY_NAME": "ROBERT M JONES",
        "FEATURES": {
            "ADDRESS": [{
                "FEAT_DESC": "111 FIRST ST LAS VEGAS NV 89111",
                "LIB_FEAT_ID": 4,
                "UTYPE_CODE": "HOME",
                "FEAT_DESC_VALUES": [{
                    "FEAT_DESC": "111 FIRST ST LAS VEGAS NV 89111",
                    "LIB_FEAT_ID": 4
                },
                {
                    "FEAT_DESC": "111 1ST ST LAS VEGAS NV 89222",
                    "LIB_FEAT_ID": 29
                }]
            },
            {
                "FEAT_DESC": "PO BOX 111 LAS VEGAS NV 89111",
                "LIB_FEAT_ID": 5,
                "UTYPE_CODE": "MAIL",
                "FEAT_DESC_VALUES": [{
                    "FEAT_DESC": "PO BOX 111 LAS VEGAS NV 89111",
                    "LIB_FEAT_ID": 5
                }]
            }],
            "DOB": [{
                "FEAT_DESC": "1981-01-02",
                "LIB_FEAT_ID": 2,
                "FEAT_DESC_VALUES": [{
                    "FEAT_DESC": "1981-01-02",
                    "LIB_FEAT_ID": 2
                },
                {
                    "FEAT_DESC": "1981-02-01",
                    "LIB_FEAT_ID": 28
                }]
            }],
            "DRLIC": [{
                "FEAT_DESC": "DL11111 NV",
                "LIB_FEAT_ID": 9,
                "FEAT_DESC_VALUES": [{
                    "FEAT_DESC": "DL11111 NV",
                    "LIB_FEAT_ID": 9
                }]
            }],
            "EMAIL": [{
                "FEAT_DESC": "BOB@JONESFAMILY.COM",
                "LIB_FEAT_ID": 12,
                "FEAT_DESC_VALUES": [{
                    "FEAT_DESC": "BOB@JONESFAMILY.COM",
                    "LIB_FEAT_ID": 12
                }]
            }],
            "GENDER": [{
                "FEAT_DESC": "M",
                "LIB_FEAT_ID": 3,
                "FEAT_DESC_VALUES": [{
                    "FEAT_DESC": "M",
                    "LIB_FEAT_ID": 3
                }]
            }],
            "LOGIN_ID": [{
                "FEAT_DESC": "@BOBJONES27",
                "LIB_FEAT_ID": 11,
                "FEAT_DESC_VALUES": [{
                    "FEAT_DESC": "@BOBJONES27",
                    "LIB_FEAT_ID": 11
                }]
            }],
            "NAME": [{
                "FEAT_DESC": "ROBERT M JONES",
                "LIB_FEAT_ID": 1,
                "UTYPE_CODE": "PRIMARY",
                "FEAT_DESC_VALUES": [{
                    "FEAT_DESC": "ROBERT M JONES",
                    "LIB_FEAT_ID": 1
                },
                {
                    "FEAT_DESC": "BOBBY JONES",
                    "LIB_FEAT_ID": 27
                }]
            }],
            "PASSPORT": [{
                "FEAT_DESC": "PP11111 US",
                "LIB_FEAT_ID": 10,
                "FEAT_DESC_VALUES": [{
                    "FEAT_DESC": "PP11111 US",
                    "LIB_FEAT_ID": 10
                }]
            }],
            "PHONE": [{
                "FEAT_DESC": "702-222-2222",
                "LIB_FEAT_ID": 6,
                "UTYPE_CODE": "CELL",
                "FEAT_DESC_VALUES": [{
                    "FEAT_DESC": "702-222-2222",
                    "LIB_FEAT_ID": 6
                }]
            },
            {
                "FEAT_DESC": "800-201-2001",
                "LIB_FEAT_ID": 7,
                "UTYPE_CODE": "WORK",
                "FEAT_DESC_VALUES": [{
                    "FEAT_DESC": "800-201-2001",
                    "LIB_FEAT_ID": 7
                }]
            }],
            "SSN": [{
                "FEAT_DESC": "311-11-1111",
                "LIB_FEAT_ID": 8,
                "FEAT_DESC_VALUES": [{
                    "FEAT_DESC": "311-11-1111",
                    "LIB_FEAT_ID": 8
                }]
            }]
        },
        "RECORD_SUMMARY": [{
            "DATA_SOURCE": "PEOPLE",
            "RECORD_COUNT": 2,
            "FIRST_SEEN_DT": "2019-03-01 00:16:24.653",
            "LAST_SEEN_DT": "2019-03-01 00:16:43.386"
        }],
        "LAST_SEEN_DT": "2019-03-01 00:16:43.386",
        "RECORDS": [{
            "JSON_DATA": {
                "ADDRESSES": [{
                    "ADDR_CITY": "Las Vegas",
                    "ADDR_COUNTRY": "US",
                    "ADDR_LINE1": "111 First St",
                    "ADDR_POSTAL_CODE": "89111",
                    "ADDR_STATE": "NV",
                    "ADDR_TYPE": "HOME"
                },
                {
                    "ADDR_CITY": "Las Vegas",
                    "ADDR_COUNTRY": "US",
                    "ADDR_LINE1": "PO Box 111",
                    "ADDR_POSTAL_CODE": "89111",
                    "ADDR_STATE": "NV",
                    "ADDR_TYPE": "MAIL"
                }],
                "DATA_SOURCE": "PEOPLE",
                "DATE_OF_BIRTH": "1/2/1981",
                "DRIVERS_LICENSE_NUMBER": "DL11111",
                "DRIVERS_LICENSE_STATE": "NV",
                "DSRC_ACTION": "A",
                "EMAIL_ADDRESS": "bob@jonesfamily.com",
                "ENTITY_TYPE": "PEOPLE",
                "GENDER": "M",
                "LOAD_ID": "sample_person.json",
                "NAMES": [{
                    "NAME_FIRST": "Robert",
                    "NAME_LAST": "Jones",
                    "NAME_MIDDLE": "M",
                    "NAME_PREFIX": "Mr",
                    "NAME_SUFFIX": "Jr",
                    "NAME_TYPE": "PRIMARY"
                }],
                "PASSPORT_COUNTRY": "US",
                "PASSPORT_NUMBER": "PP11111",
                "PHONES": [{
                    "PHONE_NUMBER": "800-201-2001",
                    "PHONE_TYPE": "WORK"
                },
                {
                    "PHONE_NUMBER": "702-222-2222",
                    "PHONE_TYPE": "CELL"
                }],
                "RECORD_ID": 1001,
                "SOCIAL_HANDLE": "@bobjones27",
                "SOCIAL_NETWORK": "twitter",
                "SSN_NUMBER": "311-11-1111"
            },
            "DATA_SOURCE": "PEOPLE",
            "ENTITY_TYPE": "PEOPLE",
            "ENTITY_KEY": "0AD619D3FA7A7C85282F28935AD7593CDB06FAE0",
            "ENTITY_NAME": "Mr Robert M Jones Jr",
            "RECORD_ID": "1001",
            "MATCH_KEY": "",
            "MATCH_SCORE": "",
            "ERRULE_CODE": "",
            "REF_SCORE": 0,
            "MATCH_LEVEL": 0,
            "LAST_SEEN_DT": "2019-03-01 00:16:24.653",
            "NAME_DATA": ["PRIMARY: Jones Robert M Mr Jr"],
            "ATTRIBUTE_DATA": ["DOB: 1/2/1981",
            "GENDER: M"],
            "IDENTIFIER_DATA": ["DRLIC: DL11111 NV",
            "EMAIL: bob@jonesfamily.com",
            "LOGIN_ID: twitter @bobjones27",
            "PASSPORT: PP11111 US",
            "SSN: 311-11-1111"],
            "ADDRESS_DATA": ["HOME: 111 First St Las Vegas NV 89111 US",
            "MAIL: PO Box 111 Las Vegas NV 89111 US"],
            "PHONE_DATA": ["WORK: 800-201-2001",
            "CELL: 702-222-2222"],
            "RELATIONSHIP_DATA": [],
            "ENTITY_DATA": [],
            "OTHER_DATA": []
        },
        {
            "JSON_DATA": {
                "ADDRESSES": [{
                    "ADDR_CITY": "Las Vegas",
                    "ADDR_LINE1": "111 1st St",
                    "ADDR_POSTAL_CODE": "89222",
                    "ADDR_STATE": "NV",
                    "ADDR_TYPE": "HOME"
                }],
                "DATA_SOURCE": "PEOPLE",
                "DATE_OF_BIRTH": "2/1/1981",
                "DSRC_ACTION": "A",
                "ENTITY_TYPE": "PEOPLE",
                "GENDER": "M",
                "LOAD_ID": "sample_person.json",
                "NAMES": [{
                    "NAME_FIRST": "Bobby",
                    "NAME_LAST": "Jones",
                    "NAME_TYPE": "PRIMARY"
                }],
                "RECORD_ID": 1002
            },
            "DATA_SOURCE": "PEOPLE",
            "ENTITY_TYPE": "PEOPLE",
            "ENTITY_KEY": "09045287B49611BDBD2E0522AFBFC91B65C7ACBB",
            "ENTITY_NAME": "Bobby Jones",
            "RECORD_ID": "1002",
            "MATCH_KEY": "+NAME+DOB+GENDER+ADDRESS",
            "MATCH_SCORE": "14",
            "ERRULE_CODE": "CNAME_CFF_CEXCL",
            "REF_SCORE": 8,
            "MATCH_LEVEL": 1,
            "LAST_SEEN_DT": "2019-03-01 00:16:43.386",
            "NAME_DATA": ["PRIMARY: Jones Bobby"],
            "ATTRIBUTE_DATA": ["DOB: 2/1/1981",
            "GENDER: M"],
            "IDENTIFIER_DATA": [],
            "ADDRESS_DATA": ["HOME: 111 1st St Las Vegas NV 89222"],
            "PHONE_DATA": [],
            "RELATIONSHIP_DATA": [],
            "ENTITY_DATA": [],
            "OTHER_DATA": []
        }]
    },
    "RELATED_ENTITIES": [{
        "ENTITY_ID": 3,
        "LENS_ID": 1,
        "MATCH_LEVEL": 2,
        "MATCH_KEY": "+PASSPORT",
        "MATCH_SCORE": "3",
        "ERRULE_CODE": "SF1E",
        "REF_SCORE": 6,
        "IS_DISCLOSED": 0,
        "IS_AMBIGUOUS": 0,
        "ENTITY_NAME": "MARTIN JONZE",
        "RECORD_SUMMARY": [{
            "DATA_SOURCE": "PEOPLE",
            "RECORD_COUNT": 1,
            "FIRST_SEEN_DT": "2019-03-01 00:16:46.832",
            "LAST_SEEN_DT": "2019-03-01 00:16:46.832"
        }],
        "LAST_SEEN_DT": "2019-03-01 00:16:46.832"
    },
    {
        "ENTITY_ID": 4,
        "LENS_ID": 1,
        "MATCH_LEVEL": 3,
        "MATCH_KEY": "+SURNAME+ADDRESS-GENDER-SSN-DRLIC-PASSPORT",
        "MATCH_SCORE": "12",
        "ERRULE_CODE": "CFF_SURNAME",
        "REF_SCORE": 4,
        "IS_DISCLOSED": 0,
        "IS_AMBIGUOUS": 0,
        "ENTITY_NAME": "ELIZABETH R JONES",
        "RECORD_SUMMARY": [{
            "DATA_SOURCE": "PEOPLE",
            "RECORD_COUNT": 1,
            "FIRST_SEEN_DT": "2019-03-01 00:16:46.842",
            "LAST_SEEN_DT": "2019-03-01 00:16:46.842"
        }],
        "LAST_SEEN_DT": "2019-03-01 00:16:46.842"
    },
    {
        "ENTITY_ID": 1001,
        "LENS_ID": 1,
        "MATCH_LEVEL": 3,
        "MATCH_KEY": "+ADDRESS+PHONE",
        "MATCH_SCORE": "4",
        "ERRULE_CODE": "MFF",
        "REF_SCORE": 4,
        "IS_DISCLOSED": 0,
        "IS_AMBIGUOUS": 0,
        "ENTITY_NAME": "PRESTO COMPANY",
        "RECORD_SUMMARY": [{
            "DATA_SOURCE": "COMPANIES",
            "RECORD_COUNT": 2,
            "FIRST_SEEN_DT": "2019-03-01 00:16:47.233",
            "LAST_SEEN_DT": "2019-03-01 00:16:57.781"
        }],
        "LAST_SEEN_DT": "2019-03-01 00:16:57.781"
    }]
}

Entity searching is a key component for interactive use of Entity Resolution intelligence. The core Senzing engine provides real-time search capabilities that are easily accessed via the Senzing API. Senzing offers methods for entity searching, all of which can be called as many times as desired and from multiple threads at the same time (and all of which return "0" upon success) .

Use getEntityByEntityIDV2() to retrieve entity data based on the ID of a resolved identity. This function accepts the following parameters as input:

Use getEntityByRecordIDV2() to retrieve entity data based on the record ID of a particular data record. This function accepts the following parameters as input:

The functions getEntityByEntityIDV2() and getEntityByRecordIDV2() are improved versions of getEntityByEntityID() and getEntityByRecordID() that also allow you to use control flags. The getEntityByEntityID() and getEntityByRecordID() functions have been deprecated.

Search By Attributes

Example code:

    dataSourceCode = 'TEST'
    recordID = 'entity_record_id'

    response = bytearray("")

    #searchByAttributes
    ret4 = engine.searchByAttributes(jsonData,response)
    print str(response)
    String dataSourceCode = "TEST";
    String recordID = "RECORD3";

    response = new StringBuffer();

/** searchByAttributes */
    int ret4 = engine.searchByAttributes(jsonData, response);
    System.out.println("GET Entity: " + response.toString());
    const char *dataSourceCode = "TEST";
    const char *recordID = "RECORD3";

    char *response = NULL;
    size_t bufSize = 0;

    //Search by entity attributes
    int ret1 = G2_searchByAttributes(jsonData, &response, &bufSize, realloc);
    printf("RECORD: %s\n", response);
    free(response);

(g2) searchByAttributes "{\"NAMES\": [{ \"NAME_TYPE\": \"PRIMARY\", \"NAME_LAST\": \"Smith\", \"NAME_FIRST\": \"John\", \"NAME_MIDDLE\": \"M\"}], \"PASSPORT_NUMBER\": \"PP11111\", \"PASSPORT_COUNTRY\": \"US\", \"DRIVERS_LICENSE_NUMBER\": \"DL11111\", \"SSN_NUMBER\": \"111-11-1111\" }"

Example return:

{
    "SEARCH_RESPONSE": {
        "RESOLVED_ENTITIES": [{
            "LENS_ID": 1,
            "ENTITY_ID": 1,
            "MATCH_LEVEL": 1,
            "MATCH_KEY": "+NAME+SSN+DRLIC+PASSPORT",
            "MATCH_SCORE": "20",
            "ERRULE_CODE": "SF1_CNAME",
            "REF_SCORE": 8,
            "ENTITY_NAME": "JOHN M SMITH",
            "FEATURES": {
                "DRLIC": [{
                    "FEAT_DESC": "DL11111",
                    "LIB_FEAT_ID": 3,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "DL11111",
                        "LIB_FEAT_ID": 3
                    }]
                }],
                "NAME": [{
                    "FEAT_DESC": "JOHN M SMITH",
                    "LIB_FEAT_ID": 1,
                    "UTYPE_CODE": "PRIMARY",
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "JOHN M SMITH",
                        "LIB_FEAT_ID": 1
                    }]
                }],
                "PASSPORT": [{
                    "FEAT_DESC": "PP11111 US",
                    "LIB_FEAT_ID": 4,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "PP11111 US",
                        "LIB_FEAT_ID": 4
                    }]
                }],
                "SSN": [{
                    "FEAT_DESC": "111-11-1111",
                    "LIB_FEAT_ID": 2,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "111-11-1111",
                        "LIB_FEAT_ID": 2
                    }]
                }]
            },
            "MATCH_SCORES": {
                "DRLIC": [{
                    "INBOUND_FEAT": "DL11111",
                    "CANDIDATE_FEAT": "DL11111",
                    "FULL_SCORE": 100
                }],
                "NAME": [{
                    "INBOUND_FEAT": "JOHN M SMITH",
                    "CANDIDATE_FEAT": "JOHN M SMITH",
                    "GNR_FN": 95,
                    "GNR_SN": 100,
                    "GNR_GN": 95,
                    "GENERATION_MATCH": -1,
                    "GNR_ON": -1
                }],
                "PASSPORT": [{
                    "INBOUND_FEAT": "PP11111 US",
                    "CANDIDATE_FEAT": "PP11111 US",
                    "FULL_SCORE": 100
                }],
                "SSN": [{
                    "INBOUND_FEAT": "111-11-1111",
                    "CANDIDATE_FEAT": "111-11-1111",
                    "FULL_SCORE": 100
                }]
            },
            "RECORDS": [{
                "JSON_DATA": {
                    "NAMES": [{
                        "NAME_TYPE": "PRIMARY",
                        "NAME_LAST": "Smith",
                        "NAME_FIRST": "John",
                        "NAME_MIDDLE": "M"
                    }],
                    "PASSPORT_NUMBER": "PP11111",
                    "PASSPORT_COUNTRY": "US",
                    "DRIVERS_LICENSE_NUMBER": "DL11111",
                    "SSN_NUMBER": "111-11-1111",
                    "DATA_SOURCE": "TEST",
                    "ENTITY_TYPE": "TEST",
                    "DSRC_ACTION": "A",
                    "LENS_CODE": "DEFAULT",
                    "RECORD_ID": "entity_record_id"
                },
                "DATA_SOURCE": "TEST",
                "ENTITY_TYPE": "TEST",
                "ENTITY_KEY": "DC22202DD6CC5FFF711D866BCF1394489FFA9180",
                "ENTITY_NAME": "John M Smith",
                "RECORD_ID": "entity_record_id",
                "MATCH_KEY": "",
                "MATCH_SCORE": "",
                "ERRULE_CODE": "",
                "REF_SCORE": 0,
                "MATCH_LEVEL": 0,
                "LAST_SEEN_DT": "2019-03-01 00:40:17.583",
                "NAME_DATA": ["PRIMARY: Smith John M"],
                "ATTRIBUTE_DATA": [],
                "IDENTIFIER_DATA": ["DRLIC: DL11111",
                "PASSPORT: PP11111 US",
                "SSN: 111-11-1111"],
                "ADDRESS_DATA": [],
                "PHONE_DATA": [],
                "RELATIONSHIP_DATA": [],
                "ENTITY_DATA": [],
                "OTHER_DATA": []
            }],
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "TEST",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 00:40:17.583",
                "LAST_SEEN_DT": "2019-03-01 00:40:17.583"
            }],
            "LAST_SEEN_DT": "2019-03-01 00:40:17.583"
        }]
    }
}

Entity searching is a key component for interactive use of Entity Resolution intelligence. The core Senzing engine provides real-time search capabilities that are easily accessed via the Senzing API. Senzing offers a method for entity searching by attributes, which can be called as many times as desired and from multiple threads at the same time (and all of which return "0" upon success) .

Use searchByAttributes() to retrieve entity data based on a user-specified set of entity attributes. This function accepts the following parameters as input:

Search By Attributes V2

Example code:

    dataSourceCode = 'TEST'
    recordID = 'entity_record_id'

    response = bytearray("")

    #searchByAttributes
    flags = 0
    ret4 = engine.searchByAttributesV2(jsonData,flags,response)
    print str(response)
    String dataSourceCode = "TEST";
    String recordID = "RECORD3";

    response = new StringBuffer();

/** searchByAttributes */
    int flags = 0;
    int ret4 = engine.searchByAttributesV2(jsonData, flags, response);
    System.out.println("GET Entity: " + response.toString());

    const char *dataSourceCode = "TEST";
    const char *recordID = "RECORD3";

    char *response = NULL;
    size_t bufSize = 0;

    //Search by entity attributes
    int flags = 0;
    int ret1 = G2_searchByAttributes_V2(jsonData, flags, &response, &bufSize, realloc);
    printf("RECORD: %s\n", response);
    free(response);
(g2) searchByAttributesV2 "{\"NAMES\": [{ \"NAME_TYPE\": \"PRIMARY\", \"NAME_LAST\": \"Smith\", \"NAME_FIRST\": \"John\", \"NAME_MIDDLE\": \"M\"}], \"PASSPORT_NUMBER\": \"PP11111\", \"PASSPORT_COUNTRY\": \"US\", \"DRIVERS_LICENSE_NUMBER\": \"DL11111\", \"SSN_NUMBER\": \"111-11-1111\" }" 0

Example return:

{
    "RESOLVED_ENTITIES": [{
        "MATCH_INFO": {
            "MATCH_LEVEL": 1,
            "MATCH_KEY": "+NAME+SSN+DRLIC+PASSPORT",
            "MATCH_SCORE": "20",
            "ERRULE_CODE": "SF1_CNAME",
            "REF_SCORE": 8,
            "FEATURE_SCORES": {
                "DRLIC": [{
                    "INBOUND_FEAT": "DL11111",
                    "CANDIDATE_FEAT": "DL11111",
                    "FULL_SCORE": 100
                }],
                "NAME": [{
                    "INBOUND_FEAT": "JOHN M SMITH",
                    "CANDIDATE_FEAT": "JOHN M SMITH",
                    "GNR_FN": 95,
                    "GNR_SN": 100,
                    "GNR_GN": 95,
                    "GENERATION_MATCH": -1,
                    "GNR_ON": -1
                }],
                "PASSPORT": [{
                    "INBOUND_FEAT": "PP11111 US",
                    "CANDIDATE_FEAT": "PP11111 US",
                    "FULL_SCORE": 100
                }],
                "SSN": [{
                    "INBOUND_FEAT": "111-11-1111",
                    "CANDIDATE_FEAT": "111-11-1111",
                    "FULL_SCORE": 100
                }]
            }
        },
        "ENTITY": {
            "RESOLVED_ENTITY": {
                "ENTITY_ID": 1,
                "LENS_ID": 1,
                "ENTITY_NAME": "JOHN M SMITH",
                "FEATURES": {
                    "DRLIC": [{
                        "FEAT_DESC": "DL11111",
                        "LIB_FEAT_ID": 3,
                        "FEAT_DESC_VALUES": [{
                            "FEAT_DESC": "DL11111",
                            "LIB_FEAT_ID": 3
                        }]
                    }],
                    "NAME": [{
                        "FEAT_DESC": "JOHN M SMITH",
                        "LIB_FEAT_ID": 1,
                        "UTYPE_CODE": "PRIMARY",
                        "FEAT_DESC_VALUES": [{
                            "FEAT_DESC": "JOHN M SMITH",
                            "LIB_FEAT_ID": 1
                        }]
                    }],
                    "PASSPORT": [{
                        "FEAT_DESC": "PP11111 US",
                        "LIB_FEAT_ID": 4,
                        "FEAT_DESC_VALUES": [{
                            "FEAT_DESC": "PP11111 US",
                            "LIB_FEAT_ID": 4
                        }]
                    }],
                    "SSN": [{
                        "FEAT_DESC": "111-11-1111",
                        "LIB_FEAT_ID": 2,
                        "FEAT_DESC_VALUES": [{
                            "FEAT_DESC": "111-11-1111",
                            "LIB_FEAT_ID": 2
                        }]
                    }]
                },
                "RECORD_SUMMARY": [{
                    "DATA_SOURCE": "TEST",
                    "RECORD_COUNT": 1,
                    "FIRST_SEEN_DT": "2019-03-01 00:40:17.583",
                    "LAST_SEEN_DT": "2019-03-01 00:40:17.583"
                }],
                "LAST_SEEN_DT": "2019-03-01 00:40:17.583",
                "RECORDS": [{
                    "JSON_DATA": {
                        "NAMES": [{
                            "NAME_TYPE": "PRIMARY",
                            "NAME_LAST": "Smith",
                            "NAME_FIRST": "John",
                            "NAME_MIDDLE": "M"
                        }],
                        "PASSPORT_NUMBER": "PP11111",
                        "PASSPORT_COUNTRY": "US",
                        "DRIVERS_LICENSE_NUMBER": "DL11111",
                        "SSN_NUMBER": "111-11-1111",
                        "DATA_SOURCE": "TEST",
                        "ENTITY_TYPE": "TEST",
                        "DSRC_ACTION": "A",
                        "LENS_CODE": "DEFAULT",
                        "RECORD_ID": "entity_record_id"
                    },
                    "DATA_SOURCE": "TEST",
                    "ENTITY_TYPE": "TEST",
                    "ENTITY_KEY": "DC22202DD6CC5FFF711D866BCF1394489FFA9180",
                    "ENTITY_NAME": "John M Smith",
                    "RECORD_ID": "entity_record_id",
                    "MATCH_KEY": "",
                    "MATCH_SCORE": "",
                    "ERRULE_CODE": "",
                    "REF_SCORE": 0,
                    "MATCH_LEVEL": 0,
                    "LAST_SEEN_DT": "2019-03-01 00:40:17.583",
                    "NAME_DATA": ["PRIMARY: Smith John M"],
                    "ATTRIBUTE_DATA": [],
                    "IDENTIFIER_DATA": ["DRLIC: DL11111",
                    "PASSPORT: PP11111 US",
                    "SSN: 111-11-1111"],
                    "ADDRESS_DATA": [],
                    "PHONE_DATA": [],
                    "RELATIONSHIP_DATA": [],
                    "ENTITY_DATA": [],
                    "OTHER_DATA": []
                }]
            },
            "RELATED_ENTITIES": []
        }
    }]
}

This function is similar but preferable to the searchByAttributes() function. This function has improved functionality and a better standardized output structure.

Use searchByAttributesV2() to retrieve entity data based on a user-specified set of entity attributes. This function accepts the following parameters as input:

Process

The process(), processWithResponse(), and processWithInfo() functions are low level functions only intended for special circumstances as directed by Senzing Support and as such will not be documented here. In general, please use addRecord(), deleteRecord(), and/or updateRecord() instead.

Maintenance

Senzing has the concept of active maintenance and part of that is noticing when more work needs to get done. Some instances where this can occur:

Processing Redo Records

Example code:

while True:
  response = bytearray([])
  if g2Engine.processRedoRecord(response) != 0:
    exit(-1) # error
  if not response:
    break # no record processed
while (true)
{
  response = new StringBuffer();
  if (g2Engine.processRedoRecord(response) != 0)
    System.exit(-1); // error
  info = new StringBuffer();
  if (g2Engine.processRedoRecordWithInfo(0, response, info) != 0)
    System.exit(-1); // error
  if (response.length() == 0)
    break; // no record processed
}

while (true)
{
  int responseSize = 64*1028;
  char* response = new char[responseSize];
  if (G2_processRedoRecord(&response, &responseSize, realloc) != 0)
    System.exit(-1); // error

  int infoSize = 64*1028;
  char* info = new char[infoSize];
  if (G2_processRedoRecordInfo(0, &response, &responseSize, &info, infoSize, realloc) != 0)
    System.exit(-1); // error

  if (response.length() == 0)
    break; // no record processed
}

Once the Senzing engine is initialized, use processRedoRecord() to process an internally queued maintenance record into the Senzing repository -- processRedoRecord() can be called as many times as desired and from multiple threads at the same time but all threads are required to be in the same process. processRedoRecord() should not be called from multiple processes. The processRedoRecord() function returns "0" upon success and an empty response if there is nothing to do.

processRedoRecordWithInfo() is available if you would like to know what resolved entities were modified when processing a redo record. It behaves identically to processRedoRecord(), but also returns a json document containing the IDs of the affected entities. It accepts the following parameters:

Retrieving Redo Records

Example code:

while True:
  response = bytearray([])
  if g2Engine.getRedoRecord(response) != 0:
    exit(-1) # error
  if not response:
    break # no record processed
  if g2Engine.process(response.decode()) != 0:
    exit(-1) # error

while (true)
{
  response = new StringBuffer();
  if (g2Engine.getRedoRecord(response) != 0)
    System.exit(-1); // error
  if (response.length() == 0)
    break; // no record processed
  if g2Engine.process(response.toString()) != 0:
    System.exit(-1); // error
}


Once the Senzing engine is initialized, use getRedoRecord() to retrieve the next internally queued maintenance record into the Senzing repository -- getRedoRecord() can be called as many times as desired and from multiple threads at the same time but all threads are required to be in the same process. getRedoRecord() should not be called from multiple processes. Unlike processRedoRecord(), getRedoRecord() does not actually process the record. To process the record, you would use the G2Engine process() function. The getRedoRecord() function returns "0" upon success and an empty response if there is nothing to do.

Count Unprocessed Redo Records

Example code:

  numRecords = g2Engine.countRedoRecords()
  long numRecords = g2Engine.countRedoRecords();

Once the Senzing engine is initialized, use countRedoRecords() to return the remaining internally queued maintenance records in the Senzing repository. countRedoRecords() takes no arguments and returns <0 for errors.

Reporting

Exporting entity data from resolved entities is one of the core purposes of Senzing software. In just a few short steps, the Senzing engine allows users to export entity data in either JSON or CSV format.

Export JSON Entity Report

Example code:

    #define the flags
    flags = 1

    #exportJSONEntityReport
    exportHandle = engine.exportJSONEntityReport(flags)

    #fetchNext
    response = bytearray()
    rowData = engine.fetchNext(exportHandle,response)
    resultString = b""
    while rowData:
        resultString += response
        response = bytearray()
        rowData = engine.fetchNext(exportHandle,response)
    print resultString

    #closeExport
    engine.closeExport(exportHandle)
    /** define the flags */
    int flags = engine.G2_EXPORT_INCLUDE_ALL_ENTITIES;

    /** exportJSONEntityReport */
    long exportHandle = engine.exportJSONEntityReport(flags);

    /** fetchNext */
    String resultString = "";
    String response = engine.fetchNext(exportHandle);
    while (response != null)
    {
        resultString.append(response);
        response = engine.fetchNext(exportHandle);
    }
    System.out.println(resultString);

    /** closeExport */
    engine.closeExport(exportHandle);
    /** define the flags */
    const int flags = G2_EXPORT_INCLUDE_ALL_ENTITIES;

    /** exportJSONEntityReport */
    ExportHandle exportHandle = G2_exportJSONEntityReport(flags);

    /** fetchNext */
    char response[64*1028];

    while (NULL != G2_fetchNext(exportHandle, response, sizeof(response))) {
        printf("Fetched: %s\n", response);
    }

    /** closeExport */
    G2_closeExport(exportHandle);
(g2) exportJSONEntityReport -f 1

Example response:

{"RESOLVED_ENTITY":{"ENTITY_ID":1,"LENS_ID":1,"ENTITY_NAME":"ROBERT M JONES","RECORD_SUMMARY":[{"DATA_SOURCE":"PEOPLE","RECORD_COUNT":2,"FIRST_SEEN_DT":"2018-12-08 00:32:11.289","LAST_SEEN_DT":"2018-12-08 00:32:17.477"}],"LAST_SEEN_DT":"2018-12-08 00:32:17.477","RECORDS":[{"JSON_DATA":{"CELL_PHONE_NUMBER":"702-222-2222","DATA_SOURCE":"PEOPLE","DATE_OF_BIRTH":"1/2/1981","DRIVERS_LICENSE_NUMBER":"DL11111","DRIVERS_LICENSE_STATE":"NV","DSRC_ACTION":"A","EMAIL_ADDRESS":"bob@jonesfamily.com","ENTITY_TYPE":"PEOPLE","GENDER":"M","HOME_ADDR_CITY":"Las Vegas","HOME_ADDR_COUNTRY":"US","HOME_ADDR_LINE1":"111 First St","HOME_ADDR_LINE2":"","HOME_ADDR_LINE3":"","HOME_ADDR_POSTAL_CODE":"89111","HOME_ADDR_STATE":"NV","LOAD_ID":"sample_person.csv","MAIL_ADDR_CITY":"Las Vegas","MAIL_ADDR_COUNTRY":"US","MAIL_ADDR_LINE1":"PO Box 111","MAIL_ADDR_LINE2":"","MAIL_ADDR_LINE3":"","MAIL_ADDR_POSTAL_CODE":"89111","MAIL_ADDR_STATE":"NV","NIN_COUNTRY":"","NIN_NUMBER":"","PASSPORT_COUNTRY":"US","PASSPORT_NUMBER":"PP11111","PRIMARY_NAME_FIRST":"Robert","PRIMARY_NAME_LAST":"Jones","PRIMARY_NAME_MIDDLE":"M","PRIMARY_NAME_PREFIX":"Mr","PRIMARY_NAME_SUFFIX":"Jr","RECORD_ID":"1001","SOCIAL_HANDLE":"@bobjones27","SOCIAL_NETWORK":"twitter","SSN_NUMBER":"311-11-1111","WORK_PHONE_NUMBER":"800-201-2001"},"DATA_SOURCE":"PEOPLE","ENTITY_TYPE":"PEOPLE","ENTITY_KEY":"543C0BB4BA18F41BF3018C5604218DB08E72F257","ENTITY_NAME":"Mr Robert M Jones Jr","RECORD_ID":"1001","MATCH_KEY":"","MATCH_SCORE":"","ERRULE_CODE":"","REF_SCORE":0,"MATCH_LEVEL":0,"LAST_SEEN_DT":"2018-12-08 00:32:11.289","NAME_DATA":["PRIMARY: Jones Robert M Mr Jr"],"ATTRIBUTE_DATA":["DOB: 1/2/1981","GENDER: M"],"IDENTIFIER_DATA":["DRLIC: DL11111 NV","EMAIL: bob@jonesfamily.com","LOGIN_ID: twitter @bobjones27","PASSPORT: PP11111 US","SSN: 311-11-1111"],"ADDRESS_DATA":["HOME: 111 First St Las Vegas NV 89111 US","MAIL: PO Box 111 Las Vegas NV 89111 US"],"PHONE_DATA":["CELL: 702-222-2222","WORK: 800-201-2001"],"RELATIONSHIP_DATA":[],"ENTITY_DATA":[],"OTHER_DATA":[]},{"JSON_DATA":{"CELL_PHONE_NUMBER":"","DATA_SOURCE":"PEOPLE","DATE_OF_BIRTH":"2/1/1981","DRIVERS_LICENSE_NUMBER":"","DRIVERS_LICENSE_STATE":"","DSRC_ACTION":"A","EMAIL_ADDRESS":"","ENTITY_TYPE":"PEOPLE","GENDER":"M","HOME_ADDR_CITY":"Las Vegas","HOME_ADDR_COUNTRY":"","HOME_ADDR_LINE1":"111 1st St","HOME_ADDR_LINE2":"","HOME_ADDR_LINE3":"","HOME_ADDR_POSTAL_CODE":"89222","HOME_ADDR_STATE":"NV","LOAD_ID":"sample_person.csv","MAIL_ADDR_CITY":"","MAIL_ADDR_COUNTRY":"","MAIL_ADDR_LINE1":"","MAIL_ADDR_LINE2":"","MAIL_ADDR_LINE3":"","MAIL_ADDR_POSTAL_CODE":"","MAIL_ADDR_STATE":"","NIN_COUNTRY":"","NIN_NUMBER":"","PASSPORT_COUNTRY":"","PASSPORT_NUMBER":"","PRIMARY_NAME_FIRST":"Bobby","PRIMARY_NAME_LAST":"Jones","PRIMARY_NAME_MIDDLE":"","PRIMARY_NAME_PREFIX":"","PRIMARY_NAME_SUFFIX":"","RECORD_ID":"1002","SOCIAL_HANDLE":"","SOCIAL_NETWORK":"","SSN_NUMBER":"","WORK_PHONE_NUMBER":""},"DATA_SOURCE":"PEOPLE","ENTITY_TYPE":"PEOPLE","ENTITY_KEY":"09045287B49611BDBD2E0522AFBFC91B65C7ACBB","ENTITY_NAME":"Bobby Jones","RECORD_ID":"1002","MATCH_KEY":"+NAME+DOB+GENDER+ADDRESS","MATCH_SCORE":"14","ERRULE_CODE":"CNAME_CFF_CEXCL","REF_SCORE":8,"MATCH_LEVEL":1,"LAST_SEEN_DT":"2018-12-08 00:32:17.477","NAME_DATA":["PRIMARY: Jones Bobby"],"ATTRIBUTE_DATA":["DOB: 2/1/1981","GENDER: M"],"IDENTIFIER_DATA":[],"ADDRESS_DATA":["HOME: 111 1st St Las Vegas NV 89222"],"PHONE_DATA":[],"RELATIONSHIP_DATA":[],"ENTITY_DATA":[],"OTHER_DATA":[]}]}}

There are three steps to exporting resolved entity data from the G2Engine object in JSON format. First, use the exportJSONEntityReport() method to generate a long integer, referred to here as an 'exportHandle'. The exportJSONEntityReport() method accepts one parameter as input:

Second, use the fetchNext() method to read the exportHandle and export a row of JSON output containing the entity data for a single entity. Note that successive calls of fetchNext() will export successive rows of entity data. The fetchNext() method accepts the following parameters as input:

Finally, use the closeExport() method to close the exportHandle and clean up system resources. This should always be called once you are finished exporting resolved entity data. The closeExport() method accepts one parameter as input:

Export CSV Entity Report

Example code:

    #define the flags
    flags = 1
    csvColumnList = "RESOLVED_ENTITY_ID,RESOLVED_ENTITY_NAME,RELATED_ENTITY_ID,MATCH_LEVEL,MATCH_KEY,IS_DISCLOSED,IS_AMBIGUOUS,DATA_SOURCE,RECORD_ID,JSON_DATA,LAST_SEEN_DT,NAME_DATA,ATTRIBUTE_DATA,IDENTIFIER_DATA,ADDRESS_DATA,PHONE_DATA,RELATIONSHIP_DATA,ENTITY_DATA,OTHER_DATA"

    #exportCSVEntityReport
    exportHandle = engine.exportCSVEntityReportV2(csvColumnList,flags)

    #fetchNext
    response = bytearray()
    rowData = engine.fetchNext(exportHandle,response)
    resultString = b""
    while rowData:
        resultString += response
        response = bytearray()
        rowData = engine.fetchNext(exportHandle,response)
    print resultString

    #closeExport
    engine.closeExport(exportHandle)
    /** define the flags */
    int flags = engine.G2_EXPORT_INCLUDE_ALL_ENTITIES;
    String csvColumnList = "RESOLVED_ENTITY_ID,RESOLVED_ENTITY_NAME,RELATED_ENTITY_ID,MATCH_LEVEL,MATCH_KEY,IS_DISCLOSED,IS_AMBIGUOUS,DATA_SOURCE,RECORD_ID,JSON_DATA,LAST_SEEN_DT,NAME_DATA,ATTRIBUTE_DATA,IDENTIFIER_DATA,ADDRESS_DATA,PHONE_DATA,RELATIONSHIP_DATA,ENTITY_DATA,OTHER_DATA";

    /** exportCSVEntityReport */
    long exportHandle = engine.exportCSVEntityReportV2(csvColumnList,flags);

    /** fetchNext */
    String resultString = "";
    String response = engine.fetchNext(exportHandle);
    while (response != null)
    {
        resultString.append(response);
        response = engine.fetchNext(exportHandle);
    }
    System.out.println(resultString);

    /** closeExport */
    engine.closeExport(exportHandle);
    /** define the flags */
    const int flags = G2_EXPORT_INCLUDE_ALL_ENTITIES;
    const char* csvColumnList = "RESOLVED_ENTITY_ID,RESOLVED_ENTITY_NAME,RELATED_ENTITY_ID,MATCH_LEVEL,MATCH_KEY,IS_DISCLOSED,IS_AMBIGUOUS,DATA_SOURCE,RECORD_ID,JSON_DATA,LAST_SEEN_DT,NAME_DATA,ATTRIBUTE_DATA,IDENTIFIER_DATA,ADDRESS_DATA,PHONE_DATA,RELATIONSHIP_DATA,ENTITY_DATA,OTHER_DATA"

    /** exportJSONEntityReport */
    ExportHandle exportHandle = G2_exportCSVEntityReport_V2(csvColumnList,flags);

    /** fetchNext */
    char response[64*1028];

    while (NULL != G2_fetchNext(exportHandle, response, sizeof(response))) {
        printf("Fetched: %s\n", response);
    }

    /** closeExport */
    G2_closeExport(exportHandle);
(g2) exportCSVEntityReportV2 -f 1 -t "RESOLVED_ENTITY_ID,RESOLVED_ENTITY_NAME,RELATED_ENTITY_ID,MATCH_LEVEL,MATCH_KEY,IS_DISCLOSED,IS_AMBIGUOUS,DATA_SOURCE,RECORD_ID,JSON_DATA,LAST_SEEN_DT,NAME_DATA,ATTRIBUTE_DATA,IDENTIFIER_DATA,ADDRESS_DATA,PHONE_DATA,RELATIONSHIP_DATA,ENTITY_DATA,OTHER_DATA"

Example response:

1,"ROBERT M JONES",0,0,"",0,0,"PEOPLE","1001","{""CELL_PHONE_NUMBER"": ""702-222-2222"", ""DATA_SOURCE"": ""PEOPLE"", ""DATE_OF_BIRTH"": ""1/2/1981"", ""DRIVERS_LICENSE_NUMBER"": ""DL11111"", ""DRIVERS_LICENSE_STATE"": ""NV"", ""DSRC_ACTION"": ""A"", ""EMAIL_ADDRESS"": ""bob@jonesfamily.com"", ""ENTITY_TYPE"": ""PEOPLE"", ""GENDER"": ""M"", ""HOME_ADDR_CITY"": ""Las Vegas"", ""HOME_ADDR_COUNTRY"": ""US"", ""HOME_ADDR_LINE1"": ""111 First St"", ""HOME_ADDR_LINE2"": """", ""HOME_ADDR_LINE3"": """", ""HOME_ADDR_POSTAL_CODE"": ""89111"", ""HOME_ADDR_STATE"": ""NV"", ""LOAD_ID"": ""sample_person.csv"", ""MAIL_ADDR_CITY"": ""Las Vegas"", ""MAIL_ADDR_COUNTRY"": ""US"", ""MAIL_ADDR_LINE1"": ""PO Box 111"", ""MAIL_ADDR_LINE2"": """", ""MAIL_ADDR_LINE3"": """", ""MAIL_ADDR_POSTAL_CODE"": ""89111"", ""MAIL_ADDR_STATE"": ""NV"", ""NIN_COUNTRY"": """", ""NIN_NUMBER"": """", ""PASSPORT_COUNTRY"": ""US"", ""PASSPORT_NUMBER"": ""PP11111"", ""PRIMARY_NAME_FIRST"": ""Robert"", ""PRIMARY_NAME_LAST"": ""Jones"", ""PRIMARY_NAME_MIDDLE"": ""M"", ""PRIMARY_NAME_PREFIX"": ""Mr"", ""PRIMARY_NAME_SUFFIX"": ""Jr"", ""RECORD_ID"": ""1001"", ""SOCIAL_HANDLE"": ""@bobjones27"", ""SOCIAL_NETWORK"": ""twitter"", ""SSN_NUMBER"": ""311-11-1111"", ""WORK_PHONE_NUMBER"": ""800-201-2001""}","2018-12-08 00:32:11.289","PRIMARY: Jones Robert M Mr Jr","DOB: 1/2/1981,GENDER: M","DRLIC: DL11111 NV,EMAIL: bob@jonesfamily.com,LOGIN_ID: twitter @bobjones27,PASSPORT: PP11111 US,SSN: 311-11-1111","HOME: 111 First St Las Vegas NV 89111 US,MAIL: PO Box 111 Las Vegas NV 89111 US","CELL: 702-222-2222,WORK: 800-201-2001","","",""

There are three steps to exporting resolved entity data from the G2Engine object in CSV format. First, use the exportCSVEntityReportV2() method to generate a long integer, referred to here as an 'exportHandle'.

The exportCSVEntityReportV2() method accepts these parameter as input:

Second, use the fetchNext() method to read the exportHandle and export a row of CSV output containing the entity data for a single entity. Note that the first call of fetchNext() will yield a header row, and that successive calls of fetchNext() will export successive rows of entity data. The fetchNext() method accepts the following parameters as input:

Finally, use the closeExport() method to close the exportHandle and clean up system resources. This should always be called once you are finished exporting resolved entity data. The closeExport() method accepts one parameter as input:

CSV Export Fields

The following fields are available for export from the CSV export calls.

Field Name Meaning
RESOLVED_ENTITY_ID Resolved entity ID
RESOLVED_ENTITY_NAME Primary name for the resolved entity
RELATED_ENTITY_ID Related Entity ID
MATCH_LEVEL Match level between records or entities
MATCH_KEY Match key between records or entities
IS_DISCLOSED Whether the relationship is disclosed
IS_AMBIGUOUS Whether the relationship is ambiguous
RECORD_ID Record ID for the specific record
DATA_SOURCE Data source for the specific record
JSON_DATA Input JSON data for the record
LAST_SEEN_DT Last seen date of the record
NAME_DATA Name data from record
ATTRIBUTE_DATA Attribute data from record
IDENTIFIER_DATA Identifier data from record
ADDRESS_DATA Address data from record
PHONE_DATA Phone data from record
RELATIONSHIP_DATA Relationship data from record
ENTITY_DATA Entity data from record
OTHER_DATA Other data from record
LENS_CODE Lens code for resolved entity
MATCH_SCORE Match score for record or relation
ERRULE_CODE ER rule code for record or relation
REF_SCORE Reference score for record or relation
ENTITY_TYPE Entity type for resolved or related entity
ENTITY_KEY Entity Key for record
ENTITY_NAME Primary name for related entity

Entity Export Flags

The Senzing engine allows you to specify the level of entity information to include in an export using exportJSONEntityReport() or exportCSVEntityReportV2() and their flag argument:

The flag values are defined in "Engine Control Flags" section. There are flags for controlling the export in particular, and also for controlling the data for the entities that are exported.

The recommended bitmask for exports is G2_EXPORT_DEFAULT_FLAGS. You may also provide custom bitmasks to determine the entity information you desire.

Export level flags control what entities you want to have exported. For instance, you many choose to export only entities that have match-level 2 relations. Or, you may export all entities in the system. (Singleton entities are single data source records that have yet to resolve or relate with other data source records. They have no existing relationships.)

Entity relationship flags control, for those entities to be exported, which relationships to give information for. You may choose to include all relationships, some relationships, or no relationships at all.

Entity feature flags control the inclusion of features on the entities returned. You may wish to see the features for an entity, or to not include the features.

These different scenarios may be achieved by adjusting the bitmask flags accordingly.

Finding Connections

Finding connections between resolved entities is one of the core purposes of Senzing software. In just a few short steps, the Senzing engine allows users to find complicated relationship chains.

Finding Paths

Example code:

    #define search variables
    entityID1 = 10
    entityID2 = 13
    maxDegree = 3
    flags = engine.G2_FIND_PATH_DEFAULT_FLAGS

    #find the path by entity ID
    response = engine.findPathByEntityIDV2(entityID1,entityID2,maxDegree,flags);

    #print the results
    print response

    #define search variables
    dataSourceCode1 = "PEOPLE"
    recordID1 = "1502"
    dataSourceCode2 = "PEOPLE"
    recordID2 = "1505"
    maxDegree = 3
    flags = engine.G2_FIND_PATH_DEFAULT_FLAGS

    #find the path by record ID
    response = engine.findPathByRecordIDV2(dataSourceCode1,recordID1,dataSourceCode2,recordID2,maxDegree,flags);

    #print the results
    print response
    /** define search variables */
    long entityID1 = 10;
    long entityID2 = 13;
    int maxDegree = 3;
    int flags = G2Engine.G2_FIND_PATH_DEFAULT_FLAGS;

    /** buffer response variables */
    StringBuffer response = new StringBuffer();

    /** find the path by entity ID */
    int ret_code = engine.findPathByEntityIDV2(entityID1,entityID2,maxDegree,flags,response);

    /** print the results */
    System.out.println("Path result document: " + response.toString());

    /** define search variables */
    String dataSourceCode1 = new String("PEOPLE");
    String recordID1 = new String("1502");
    String dataSourceCode2 = new String("PEOPLE");
    String recordID2 = new String("1505");

    /** find the path by record ID */
    ret_code = engine.findPathByRecordIDV2(dataSourceCode1,recordID1,dataSourceCode2,recordID2,maxDegree,flags,response);

    /** print the results */
    System.out.println("Path result document: " + response.toString());
    /** define search variables */
    const long long entityID1 = 10;
    const long long entityID2 = 13;
    const int maxDegree = 3;
    const int flags = G2_FIND_PATH_DEFAULT_FLAGS;

    /** buffer response variables */
    char *response = NULL;
    size_t bufSize = 0;

    /** find the path by entity ID */
    int ret_code = G2_findPathByEntityID_V2(entityID1,entityID2,maxDegree,flags,&response,&bufSize,realloc);

    /** print the results */
    printf("Path result document: %s\n", response);

    /** define search variables */
    const char* dataSourceCode1 = "PEOPLE";
    const char* recordID1 = "1502";
    const char* dataSourceCode2 = "PEOPLE";
    const char* recordID2 = "1505";

    /** find the path by record ID */
    ret_code = G2_findPathByRecordID_V2(dataSourceCode1,recordID1,dataSourceCode2,recordID2,maxDegree,flags,&response,&bufSize,realloc);

    /** print the results */
    printf("Path result document: %s\n", response);
(g2) findPathByEntityIDV2 10 13 3 4352

(g2) findPathByRecordIDV2 PEOPLE 1502 PEOPLE 1505 3 4352

Example output:

{
    "ENTITY_PATHS": [{
        "START_ENTITY_ID": 10,
        "END_ENTITY_ID": 13,
        "ENTITIES": [10,
        11,
        12,
        13]
    }],
    "ENTITIES": [{
        "RESOLVED_ENTITY": {
            "ENTITY_ID": 10,
            "LENS_ID": 1,
            "ENTITY_NAME": "",
            "FEATURES": {
                "DRLIC": [{
                    "FEAT_DESC": "DL5559999 NV",
                    "LIB_FEAT_ID": 64,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "DL5559999 NV",
                        "LIB_FEAT_ID": 64
                    }]
                }],
                "PASSPORT": [{
                    "FEAT_DESC": "PP4444777 US",
                    "LIB_FEAT_ID": 61,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "PP4444777 US",
                        "LIB_FEAT_ID": 61
                    }]
                }]
            },
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.164",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.164"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.164",
            "RECORDS": [{
                "JSON_DATA": {
                    "CELL_PHONE_NUMBER": "",
                    "DATA_SOURCE": "PEOPLE",
                    "DATE_OF_BIRTH": "",
                    "DRIVERS_LICENSE_NUMBER": "DL5559999",
                    "DRIVERS_LICENSE_STATE": "NV",
                    "DSRC_ACTION": "A",
                    "EMAIL_ADDRESS": "",
                    "ENTITY_TYPE": "PEOPLE",
                    "GENDER": "",
                    "HOME_ADDR_CITY": "",
                    "HOME_ADDR_COUNTRY": "",
                    "HOME_ADDR_LINE1": "",
                    "HOME_ADDR_LINE2": "",
                    "HOME_ADDR_LINE3": "",
                    "HOME_ADDR_POSTAL_CODE": "",
                    "HOME_ADDR_STATE": "",
                    "LOAD_ID": "sample_person.csv",
                    "MAIL_ADDR_CITY": "",
                    "MAIL_ADDR_COUNTRY": "",
                    "MAIL_ADDR_LINE1": "",
                    "MAIL_ADDR_LINE2": "",
                    "MAIL_ADDR_LINE3": "",
                    "MAIL_ADDR_POSTAL_CODE": "",
                    "MAIL_ADDR_STATE": "",
                    "NIN_COUNTRY": "",
                    "NIN_NUMBER": "",
                    "PASSPORT_COUNTRY": "US",
                    "PASSPORT_NUMBER": "PP4444777",
                    "PRIMARY_NAME_FIRST": "",
                    "PRIMARY_NAME_LAST": "",
                    "PRIMARY_NAME_MIDDLE": "",
                    "PRIMARY_NAME_PREFIX": "",
                    "PRIMARY_NAME_SUFFIX": "",
                    "RECORD_ID": "1502",
                    "SOCIAL_HANDLE": "",
                    "SOCIAL_NETWORK": "",
                    "SSN_NUMBER": "",
                    "WORK_PHONE_NUMBER": ""
                },
                "DATA_SOURCE": "PEOPLE",
                "ENTITY_TYPE": "PEOPLE",
                "ENTITY_KEY": "B191ABC8BD8592B55A1791E79B16ACA6B9F8603B",
                "ENTITY_NAME": "",
                "RECORD_ID": "1502",
                "MATCH_KEY": "",
                "MATCH_SCORE": "",
                "ERRULE_CODE": "",
                "REF_SCORE": 0,
                "MATCH_LEVEL": 0,
                "LAST_SEEN_DT": "2019-03-01 01:42:23.164",
                "NAME_DATA": [],
                "ATTRIBUTE_DATA": [],
                "IDENTIFIER_DATA": ["DRLIC: DL5559999 NV",
                "PASSPORT: PP4444777 US"],
                "ADDRESS_DATA": [],
                "PHONE_DATA": [],
                "RELATIONSHIP_DATA": [],
                "ENTITY_DATA": [],
                "OTHER_DATA": []
            }]
        },
        "RELATED_ENTITIES": [{
            "ENTITY_ID": 9,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+PASSPORT-DRLIC",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.160",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.160"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.160"
        },
        {
            "ENTITY_ID": 11,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+DRLIC-PASSPORT",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.168",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.168"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.168"
        }]
    },
    {
        "RESOLVED_ENTITY": {
            "ENTITY_ID": 11,
            "LENS_ID": 1,
            "ENTITY_NAME": "",
            "FEATURES": {
                "DRLIC": [{
                    "FEAT_DESC": "DL5559999 NV",
                    "LIB_FEAT_ID": 64,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "DL5559999 NV",
                        "LIB_FEAT_ID": 64
                    }]
                }],
                "PASSPORT": [{
                    "FEAT_DESC": "PP9984564 US",
                    "LIB_FEAT_ID": 67,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "PP9984564 US",
                        "LIB_FEAT_ID": 67
                    }]
                }],
                "SSN": [{
                    "FEAT_DESC": "425-23-3242",
                    "LIB_FEAT_ID": 66,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "425-23-3242",
                        "LIB_FEAT_ID": 66
                    }]
                }]
            },
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.168",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.168"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.168",
            "RECORDS": [{
                "JSON_DATA": {
                    "CELL_PHONE_NUMBER": "",
                    "DATA_SOURCE": "PEOPLE",
                    "DATE_OF_BIRTH": "",
                    "DRIVERS_LICENSE_NUMBER": "DL5559999",
                    "DRIVERS_LICENSE_STATE": "NV",
                    "DSRC_ACTION": "A",
                    "EMAIL_ADDRESS": "",
                    "ENTITY_TYPE": "PEOPLE",
                    "GENDER": "",
                    "HOME_ADDR_CITY": "",
                    "HOME_ADDR_COUNTRY": "",
                    "HOME_ADDR_LINE1": "",
                    "HOME_ADDR_LINE2": "",
                    "HOME_ADDR_LINE3": "",
                    "HOME_ADDR_POSTAL_CODE": "",
                    "HOME_ADDR_STATE": "",
                    "LOAD_ID": "sample_person.csv",
                    "MAIL_ADDR_CITY": "",
                    "MAIL_ADDR_COUNTRY": "",
                    "MAIL_ADDR_LINE1": "",
                    "MAIL_ADDR_LINE2": "",
                    "MAIL_ADDR_LINE3": "",
                    "MAIL_ADDR_POSTAL_CODE": "",
                    "MAIL_ADDR_STATE": "",
                    "NIN_COUNTRY": "",
                    "NIN_NUMBER": "",
                    "PASSPORT_COUNTRY": "US",
                    "PASSPORT_NUMBER": "PP9984564",
                    "PRIMARY_NAME_FIRST": "",
                    "PRIMARY_NAME_LAST": "",
                    "PRIMARY_NAME_MIDDLE": "",
                    "PRIMARY_NAME_PREFIX": "",
                    "PRIMARY_NAME_SUFFIX": "",
                    "RECORD_ID": "1503",
                    "SOCIAL_HANDLE": "",
                    "SOCIAL_NETWORK": "",
                    "SSN_NUMBER": "425-23-3242",
                    "WORK_PHONE_NUMBER": ""
                },
                "DATA_SOURCE": "PEOPLE",
                "ENTITY_TYPE": "PEOPLE",
                "ENTITY_KEY": "B879D5E07F5DEEA0170274F8EE4F4D7F2A73D8D4",
                "ENTITY_NAME": "",
                "RECORD_ID": "1503",
                "MATCH_KEY": "",
                "MATCH_SCORE": "",
                "ERRULE_CODE": "",
                "REF_SCORE": 0,
                "MATCH_LEVEL": 0,
                "LAST_SEEN_DT": "2019-03-01 01:42:23.168",
                "NAME_DATA": [],
                "ATTRIBUTE_DATA": [],
                "IDENTIFIER_DATA": ["DRLIC: DL5559999 NV",
                "PASSPORT: PP9984564 US",
                "SSN: 425-23-3242"],
                "ADDRESS_DATA": [],
                "PHONE_DATA": [],
                "RELATIONSHIP_DATA": [],
                "ENTITY_DATA": [],
                "OTHER_DATA": []
            }]
        },
        "RELATED_ENTITIES": [{
            "ENTITY_ID": 10,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+DRLIC-PASSPORT",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.164",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.164"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.164"
        },
        {
            "ENTITY_ID": 12,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+PASSPORT-DRLIC",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.173",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.173"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.173"
        },
        {
            "ENTITY_ID": 15,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+SSN-DRLIC-PASSPORT",
            "MATCH_SCORE": "4",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "COMPANIES",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.189",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.189"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.189"
        }]
    },
    {
        "RESOLVED_ENTITY": {
            "ENTITY_ID": 12,
            "LENS_ID": 1,
            "ENTITY_NAME": "",
            "FEATURES": {
                "DRLIC": [{
                    "FEAT_DESC": "DL7837747 NV",
                    "LIB_FEAT_ID": 70,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "DL7837747 NV",
                        "LIB_FEAT_ID": 70
                    }]
                }],
                "PASSPORT": [{
                    "FEAT_DESC": "PP9984564 US",
                    "LIB_FEAT_ID": 67,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "PP9984564 US",
                        "LIB_FEAT_ID": 67
                    }]
                }]
            },
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.173",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.173"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.173",
            "RECORDS": [{
                "JSON_DATA": {
                    "CELL_PHONE_NUMBER": "",
                    "DATA_SOURCE": "PEOPLE",
                    "DATE_OF_BIRTH": "",
                    "DRIVERS_LICENSE_NUMBER": "DL7837747",
                    "DRIVERS_LICENSE_STATE": "NV",
                    "DSRC_ACTION": "A",
                    "EMAIL_ADDRESS": "",
                    "ENTITY_TYPE": "PEOPLE",
                    "GENDER": "",
                    "HOME_ADDR_CITY": "",
                    "HOME_ADDR_COUNTRY": "",
                    "HOME_ADDR_LINE1": "",
                    "HOME_ADDR_LINE2": "",
                    "HOME_ADDR_LINE3": "",
                    "HOME_ADDR_POSTAL_CODE": "",
                    "HOME_ADDR_STATE": "",
                    "LOAD_ID": "sample_person.csv",
                    "MAIL_ADDR_CITY": "",
                    "MAIL_ADDR_COUNTRY": "",
                    "MAIL_ADDR_LINE1": "",
                    "MAIL_ADDR_LINE2": "",
                    "MAIL_ADDR_LINE3": "",
                    "MAIL_ADDR_POSTAL_CODE": "",
                    "MAIL_ADDR_STATE": "",
                    "NIN_COUNTRY": "",
                    "NIN_NUMBER": "",
                    "PASSPORT_COUNTRY": "US",
                    "PASSPORT_NUMBER": "PP9984564",
                    "PRIMARY_NAME_FIRST": "",
                    "PRIMARY_NAME_LAST": "",
                    "PRIMARY_NAME_MIDDLE": "",
                    "PRIMARY_NAME_PREFIX": "",
                    "PRIMARY_NAME_SUFFIX": "",
                    "RECORD_ID": "1504",
                    "SOCIAL_HANDLE": "",
                    "SOCIAL_NETWORK": "",
                    "SSN_NUMBER": "",
                    "WORK_PHONE_NUMBER": ""
                },
                "DATA_SOURCE": "PEOPLE",
                "ENTITY_TYPE": "PEOPLE",
                "ENTITY_KEY": "D2F995CC4222EB3B3AE1E61C446DA8554DE28D89",
                "ENTITY_NAME": "",
                "RECORD_ID": "1504",
                "MATCH_KEY": "",
                "MATCH_SCORE": "",
                "ERRULE_CODE": "",
                "REF_SCORE": 0,
                "MATCH_LEVEL": 0,
                "LAST_SEEN_DT": "2019-03-01 01:42:23.173",
                "NAME_DATA": [],
                "ATTRIBUTE_DATA": [],
                "IDENTIFIER_DATA": ["DRLIC: DL7837747 NV",
                "PASSPORT: PP9984564 US"],
                "ADDRESS_DATA": [],
                "PHONE_DATA": [],
                "RELATIONSHIP_DATA": [],
                "ENTITY_DATA": [],
                "OTHER_DATA": []
            }]
        },
        "RELATED_ENTITIES": [{
            "ENTITY_ID": 11,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+PASSPORT-DRLIC",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.168",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.168"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.168"
        },
        {
            "ENTITY_ID": 13,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+DRLIC-PASSPORT",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.178",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.178"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.178"
        }]
    },
    {
        "RESOLVED_ENTITY": {
            "ENTITY_ID": 13,
            "LENS_ID": 1,
            "ENTITY_NAME": "",
            "FEATURES": {
                "DRLIC": [{
                    "FEAT_DESC": "DL7837747 NV",
                    "LIB_FEAT_ID": 70,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "DL7837747 NV",
                        "LIB_FEAT_ID": 70
                    }]
                }],
                "PASSPORT": [{
                    "FEAT_DESC": "PP9683646 US",
                    "LIB_FEAT_ID": 72,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "PP9683646 US",
                        "LIB_FEAT_ID": 72
                    }]
                }]
            },
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.178",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.178"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.178",
            "RECORDS": [{
                "JSON_DATA": {
                    "CELL_PHONE_NUMBER": "",
                    "DATA_SOURCE": "PEOPLE",
                    "DATE_OF_BIRTH": "",
                    "DRIVERS_LICENSE_NUMBER": "DL7837747",
                    "DRIVERS_LICENSE_STATE": "NV",
                    "DSRC_ACTION": "A",
                    "EMAIL_ADDRESS": "",
                    "ENTITY_TYPE": "PEOPLE",
                    "GENDER": "",
                    "HOME_ADDR_CITY": "",
                    "HOME_ADDR_COUNTRY": "",
                    "HOME_ADDR_LINE1": "",
                    "HOME_ADDR_LINE2": "",
                    "HOME_ADDR_LINE3": "",
                    "HOME_ADDR_POSTAL_CODE": "",
                    "HOME_ADDR_STATE": "",
                    "LOAD_ID": "sample_person.csv",
                    "MAIL_ADDR_CITY": "",
                    "MAIL_ADDR_COUNTRY": "",
                    "MAIL_ADDR_LINE1": "",
                    "MAIL_ADDR_LINE2": "",
                    "MAIL_ADDR_LINE3": "",
                    "MAIL_ADDR_POSTAL_CODE": "",
                    "MAIL_ADDR_STATE": "",
                    "NIN_COUNTRY": "",
                    "NIN_NUMBER": "",
                    "PASSPORT_COUNTRY": "US",
                    "PASSPORT_NUMBER": "PP9683646",
                    "PRIMARY_NAME_FIRST": "",
                    "PRIMARY_NAME_LAST": "",
                    "PRIMARY_NAME_MIDDLE": "",
                    "PRIMARY_NAME_PREFIX": "",
                    "PRIMARY_NAME_SUFFIX": "",
                    "RECORD_ID": "1505",
                    "SOCIAL_HANDLE": "",
                    "SOCIAL_NETWORK": "",
                    "SSN_NUMBER": "",
                    "WORK_PHONE_NUMBER": ""
                },
                "DATA_SOURCE": "PEOPLE",
                "ENTITY_TYPE": "PEOPLE",
                "ENTITY_KEY": "42BC48A37138228ACDF30D34A9B84CD7FA3294F0",
                "ENTITY_NAME": "",
                "RECORD_ID": "1505",
                "MATCH_KEY": "",
                "MATCH_SCORE": "",
                "ERRULE_CODE": "",
                "REF_SCORE": 0,
                "MATCH_LEVEL": 0,
                "LAST_SEEN_DT": "2019-03-01 01:42:23.178",
                "NAME_DATA": [],
                "ATTRIBUTE_DATA": [],
                "IDENTIFIER_DATA": ["DRLIC: DL7837747 NV",
                "PASSPORT: PP9683646 US"],
                "ADDRESS_DATA": [],
                "PHONE_DATA": [],
                "RELATIONSHIP_DATA": [],
                "ENTITY_DATA": [],
                "OTHER_DATA": []
            }]
        },
        "RELATED_ENTITIES": [{
            "ENTITY_ID": 12,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+DRLIC-PASSPORT",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.173",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.173"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.173"
        },
        {
            "ENTITY_ID": 14,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+PASSPORT-DRLIC",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.184",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.184"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.184"
        }]
    }]
}

The FindPathByEntityIDV2() and FindPathByRecordIDV2() functions can be used to find single relationship paths between two entities. Paths are found using known relationships with other entities.

Entities can be searched for by either Entity ID or by Record ID, depending on which function is chosen.

These functions have the following parameters:

They also have various arguments used to return response documents.

The functions return a JSON document that identifies the path between the entities, and the information on the entities in question. The document contains a section called "ENTITY_PATHS" which gives the path from one entity to the other (such as { "START_ENTITY_ID": 10, "END_ENTITY_ID": 13, "ENTITIES": [10, 11, 12, 13] }.) If no path was found, then the value of ENTITIES will be an empty list.

The response document also contains a separate ENTITIES section, with the full information about the resolved entities along that path.

The functions FindPathByEntityIDV2() and FindPathByRecordIDV2() are improved versions of FindPathByEntityID() and FindPathByRecordID() that also allow you to use control flags. The FindPathByEntityID() and FindPathByRecordID() functions are deprecated.

Finding Paths with Exclusions

Example code:

    #define search variables
    entityID1 = 10
    entityID2 = 13
    maxDegree = 4
    excludedEntities = "{\"ENTITIES\":[{\"ENTITY_ID\":\"27\"}]}"
    flags = 0

    #find the path by entity ID
    response = engine.findPathExcludingByEntityID(entityID1,entityID2,maxDegree,excludedEntities,flags);

    #print the results
    print response

    #define search variables
    dataSourceCode1 = "PEOPLE"
    recordID1 = "1502"
    dataSourceCode2 = "PEOPLE"
    recordID2 = "1505"
    excludedRecords = "{\"RECORDS\":[{\"RECORD_ID\":\"1537\",\"DATA_SOURCE\":\"PEOPLE\"}]}"

    #find the path by record ID
    response = engine.findPathExcludingByRecordID(dataSourceCode1,recordID1,dataSourceCode2,recordID2,maxDegree,excludedRecords,flags);

    #print the results
    print response
    /** define search variables */
    long entityID1 = 10;
    long entityID2 = 13;
    int maxDegree = 4;
    String excludedEntities = new String("{\"ENTITIES\":[{\"ENTITY_ID\":\"27\"}]}");
    int flags = 0;

    /** buffer response variables */
    StringBuffer response = new StringBuffer();

    /** find the path by entity ID */
    int ret_code = engine.findPathExcludingByEntityID(entityID1,entityID2,maxDegree,excludedEntities,flags,response);

    /** print the results */
    System.out.println("Path result document: " + response.toString());

    /** define search variables */
    String dataSourceCode1 = new String("PEOPLE");
    String recordID1 = new String("1502");
    String dataSourceCode2 = new String("PEOPLE");
    String recordID2 = new String("1505");
    String excludedRecords = new String("{\"RECORDS\":[{\"RECORD_ID\":\"1537\",\"DATA_SOURCE\":\"PEOPLE\"}]}");

    /** find the path by record ID */
    ret_code = engine.findPathExcludingByRecordID(dataSourceCode1,recordID1,dataSourceCode2,recordID2,maxDegree,excludedRecords,flags,response);

    /** print the results */
    System.out.println("Path result document: " + response.toString());
    /** define search variables */
    const long long entityID1 = 10;
    const long long entityID2 = 13;
    const int maxDegree = 4;
    const char* excludedEntities = "{\"ENTITIES\":[{\"ENTITY_ID\":\"27\"}]}";
    int flags = 0;

    /** buffer response variables */
    char *response = NULL;
    size_t bufSize = 0;

    /** find the path by entity ID */
    int ret_code = G2_findPathExcludingByEntityID(entityID1,entityID2,maxDegree,excludedEntities,flags,&response,&bufSize,realloc);

    /** print the results */
    printf("Path result document: %s\n", response);

    /** define search variables */
    const char* dataSourceCode1 = "PEOPLE";
    const char* recordID1 = "1502";
    const char* dataSourceCode2 = "PEOPLE";
    const char* recordID2 = "1505";
    const char* excludedRecords = "{\"RECORDS\":[{\"RECORD_ID\":\"1537\",\"DATA_SOURCE\":\"PEOPLE\"}]}";

    /** find the path by record ID */
    ret_code = G2_findPathExcludingByRecordID(dataSourceCode1,recordID1,dataSourceCode2,recordID2,maxDegree,excludedRecords,flags,&response,&bufSize,realloc);

    /** print the results */
    printf("Path result document: %s\n", response);
(g2) findPathExcludingByEntityID 10 13 4 "{\"ENTITIES\":[{\"ENTITY_ID\":\"27\"}]}" 0

(g2) findPathExcludingByRecordID PEOPLE 1502 PEOPLE 1505 4 "{\"RECORDS\":[{\"RECORD_ID\":\"1537\",\"DATA_SOURCE\":\"PEOPLE\"}]}" 0

Example response is identical to FindPathByEntityIDV2() and FindPathByRecordIDV2() functions.

The FindPathExcludingByEntityID() and FindPathExcludingByRecordID() functions can be used to find single relationship paths between two entities. Paths are found using known relationships with other entities. In addition, it will find paths that exclude certain entities from being on the path.

Entities can be searched for by either Entity ID or by Record ID, depending on which function is chosen. Additionally, entities to be excluded can also be specified by either Entity ID or by Record ID.

When excluding entities, the user may choose to either (a) strictly exclude the entities, or (b) prefer to exclude the entities, but still include them if no other path is found. By default, entities will be strictly excluded. A "preferred exclude" may be done by specifying the G2_FIND_PATH_PREFER_EXCLUDE control flag.

These functions have the following parameters:

They also have various arguments used to return response documents.

The functions return a JSON document that identifies the path between the entities, and the information on the entities in question. The document format is identical to the FindPathByEntityIDV2() and FindPathByRecordIDV2() functions.

Finding Paths with Required Sources

Example code:

    #define search variables
    entityID1 = 10
    entityID2 = 13
    maxDegree = 4
    excludedEntities = "{\"ENTITIES\":[{\"ENTITY_ID\":\"27\"}]}"
    requiredDsrcs = "{\"DATA_SOURCES\":[\"PEOPLE\"]}"
    flags = 0

    #find the path by entity ID
    response = engine.findPathIncludingSourceByEntityID(entityID1,entityID2,maxDegree,excludedEntities,requiredDsrcs,flags);

    #print the results
    print response

    #define search variables
    dataSourceCode1 = "PEOPLE"
    recordID1 = "1502"
    dataSourceCode2 = "PEOPLE"
    recordID2 = "1505"
    excludedRecords = "{\"RECORDS\":[{\"RECORD_ID\":\"1537\",\"DATA_SOURCE\":\"PEOPLE\"}]}"

    #find the path by record ID
    response = engine.findPathIncludingSourceByRecordID(dataSourceCode1,recordID1,dataSourceCode2,recordID2,maxDegree,excludedRecords,requiredDsrcs,flags);

    #print the results
    print response
    /** define search variables */
    long entityID1 = 10;
    long entityID2 = 13;
    int maxDegree = 4;
    String excludedEntities = new String("{\"ENTITIES\":[{\"ENTITY_ID\":\"27\"}]}");
    String requiredDsrcs = new String("{\"DATA_SOURCES\":[\"PEOPLE\"]}");
    int flags = 0;

    /** buffer response variables */
    StringBuffer response = new StringBuffer();

    /** find the path by entity ID */
    int ret_code = engine.findPathIncludingSourceByEntityID(entityID1,entityID2,maxDegree,excludedEntities,requiredDsrcs,flags,response);

    /** print the results */
    System.out.println("Path result document: " + response.toString());

    /** define search variables */
    String dataSourceCode1 = new String("PEOPLE");
    String recordID1 = new String("1502");
    String dataSourceCode2 = new String("PEOPLE");
    String recordID2 = new String("1505");
    String excludedRecords = new String("{\"RECORDS\":[{\"RECORD_ID\":\"1537\",\"DATA_SOURCE\":\"PEOPLE\"}]}");

    /** find the path by record ID */
    ret_code = engine.findPathIncludingSourceByRecordID(dataSourceCode1,recordID1,dataSourceCode2,recordID2,maxDegree,excludedRecords,requiredDsrcs,flags,response);

    /** print the results */
    System.out.println("Path result document: " + response.toString());
    /** define search variables */
    const long long entityID1 = 10;
    const long long entityID2 = 13;
    const int maxDegree = 4;
    const char* excludedEntities = "{\"ENTITIES\":[{\"ENTITY_ID\":\"27\"}]}";
    const char* requiredDsrcs = "{\"DATA_SOURCES\":[\"PEOPLE\"]}";
    int flags = 0;

    /** buffer response variables */
    char *response = NULL;
    size_t bufSize = 0;

    /** find the path by entity ID */
    int ret_code = G2_findPathIncludingSourceByEntityID(entityID1,entityID2,maxDegree,excludedEntities,requiredDsrcs,flags,&response,&bufSize,realloc);

    /** print the results */
    printf("Path result document: %s\n", response);

    /** define search variables */
    const char* dataSourceCode1 = "PEOPLE";
    const char* recordID1 = "1502";
    const char* dataSourceCode2 = "PEOPLE";
    const char* recordID2 = "1505";
    const char* excludedRecords = "{\"RECORDS\":[{\"RECORD_ID\":\"1537\",\"DATA_SOURCE\":\"PEOPLE\"}]}";

    /** find the path by record ID */
    ret_code = G2_findPathIncludingSourceByRecordID(dataSourceCode1,recordID1,dataSourceCode2,recordID2,maxDegree,excludedRecords,requiredDsrcs,flags,&response,&bufSize,realloc);

    /** print the results */
    printf("Path result document: %s\n", response);
(g2) findPathIncludingSourceByEntityID 10 13 4 "{\"ENTITIES\":[{\"ENTITY_ID\":\"27\"}]}" "{\"DATA_SOURCES\":[\"PEOPLE\"]}" 0

(g2) findPathIncludingSourceByRecordID PEOPLE 1502 PEOPLE 1505 4 "{\"RECORDS\":[{\"RECORD_ID\":\"1537\",\"DATA_SOURCE\":\"PEOPLE\"}]}" "{\"DATA_SOURCES\":[\"PEOPLE\"]}" 0

Example response is identical to FindPathByEntityIDV2() and FindPathByRecordIDV2() functions.

The FindPathIncludingSourceByEntityID() and FindPathIncludingSourceByRecordID() functions can be used to find single relationship paths between two entities. In addition, one of the entities along the path must include a specified data source.

To illustrate, a user may search for a path between entities A and B, but only if the path contains a required data source. They may specify a list of data sources to use in searching for the path. Then, a path of A-->C-->B would only be found if entity C contained at least one of the specified data sources. (Entities A and B would not be checked for the required data sources, as those two entities are already known prior to the search.)

If the list of required data sources is empty, then the list will be ignored. This function will return an entity path without checking to see what data sources are on the path.

Entities can be searched for by either Entity ID or by Record ID, depending on which function is chosen. The required data source or sources are specified by a json document list.

Specific entities may also be excluded, using the same methodology as the FindPathExcludingByEntityID() and FindPathExcludingByRecordID() functions use.

These functions have the following parameters:

They also have various arguments used to return response documents.

The functions return a JSON document that identifies the path between the entities, and the information on the entities in question. The document format is identical to the FindPathByEntityIDV2() and FindPathByRecordIDV2() functions.

Finding Networks

Example code:

    #define search variables
    entityList = "{\"ENTITIES\":[{\"ENTITY_ID\":\"10\"},{\"ENTITY_ID\":\"15\"},{\"ENTITY_ID\":\"13\"}]}"
    maxDegree = 2
    buildOutDegree = 1
    maxEntities = 12
    flags = engine.G2_FIND_PATH_DEFAULT_FLAGS

    #find the network by entity ID
    response = engine.findNetworkByEntityIDV2(entityList,maxDegree,buildOutDegree,maxEntities,flags);

    #print the results
    print response

    #define search variables
    recordList = "{\"RECORDS\":[{\"RECORD_ID\":\"1502\",\"DATA_SOURCE\":\"PEOPLE\"},{\"RECORD_ID\":\"1507\",\"DATA_SOURCE\":\"PEOPLE\"},{\"RECORD_ID\":\"1505\",\"DATA_SOURCE\":\"PEOPLE\"}]}"

    #find the network by record ID
    response = engine.findNetworkByRecordIDV2(recordList,maxDegree,buildOutDegree,maxEntities,flags);

    #print the results
    print response
    /** define search variables */
    String entityList = new String("{\"ENTITIES\":[{\"ENTITY_ID\":\"10\"},{\"ENTITY_ID\":\"15\"},{\"ENTITY_ID\":\"13\"}]}");
    int maxDegree = 2;
    int buildOutDegree = 1;
    int maxEntities = 12;
    int flags = G2Engine.G2_FIND_PATH_DEFAULT_FLAGS;

    /** buffer response variables */
    StringBuffer response = new StringBuffer();

    /** find the network by entity ID */
    int ret_code = engine.findNetworkByEntityIDV2(entityList,maxDegree,buildOutDegree,maxEntities,flags,response);

    /** print the results */
    System.out.println("Network result document: " + response.toString());

    /** define search variables */
    String recordList = new String("{\"RECORDS\":[{\"RECORD_ID\":\"1502\",\"DATA_SOURCE\":\"PEOPLE\"},{\"RECORD_ID\":\"1507\",\"DATA_SOURCE\":\"PEOPLE\"},{\"RECORD_ID\":\"1505\",\"DATA_SOURCE\":\"PEOPLE\"}]}");

    /** find the network by record ID */
    ret_code = engine.findPathNetworkRecordIDV2(recordList,maxDegree,buildOutDegree,maxEntities,flags,response);

    /** print the results */
    System.out.println("Network result document: " + response.toString());
    /** define search variables */
    const char* entityList = "{\"ENTITIES\":[{\"ENTITY_ID\":\"10\"},{\"ENTITY_ID\":\"15\"},{\"ENTITY_ID\":\"13\"}]}"
    int maxDegree = 2;
    int buildOutDegree = 1;
    int maxEntities = 12;
    const int flags = G2_FIND_PATH_DEFAULT_FLAGS;

    /** buffer response variables */
    char *response = NULL;
    size_t bufSize = 0;

    /** find the network by entity ID */
    int ret_code = G2_findPathNetworkEntityID_V2(entityList,maxDegree,buildOutDegree,maxEntities,flags,&response,&bufSize,realloc);

    /** print the results */
    printf("Network result document: %s\n", response);

    /** define search variables */
    const char* recordList = "{\"RECORDS\":[{\"RECORD_ID\":\"1502\",\"DATA_SOURCE\":\"PEOPLE\"},{\"RECORD_ID\":\"1507\",\"DATA_SOURCE\":\"PEOPLE\"},{\"RECORD_ID\":\"1505\",\"DATA_SOURCE\":\"PEOPLE\"}]}"

    /** find the network by record ID */
    ret_code = G2_findNetworkByRecordID_V2(recordList,maxDegree,buildOutDegree,maxEntities,flags,&response,&bufSize,realloc);

    /** print the results */
    printf("Network result document: %s\n", response);
(g2) findNetworkByEntityIDV2 "{\"ENTITIES\":[{\"ENTITY_ID\":\"10\"},{\"ENTITY_ID\":\"15\"},{\"ENTITY_ID\":\"13\"}]}" 2 1 12 4352

(g2) findNetworkByRecordIDV2 "{\"RECORDS\":[{\"RECORD_ID\":\"1502\",\"DATA_SOURCE\":\"PEOPLE\"},{\"RECORD_ID\":\"1507\",\"DATA_SOURCE\":\"PEOPLE\"},{\"RECORD_ID\":\"1505\",\"DATA_SOURCE\":\"PEOPLE\"}]}" 2 1 12 4352

Example output:

{
    "ENTITY_PATHS": [{
        "START_ENTITY_ID": 10,
        "END_ENTITY_ID": 13,
        "ENTITIES": []
    },
    {
        "START_ENTITY_ID": 10,
        "END_ENTITY_ID": 15,
        "ENTITIES": [10,
        11,
        15]
    },
    {
        "START_ENTITY_ID": 13,
        "END_ENTITY_ID": 15,
        "ENTITIES": [13,
        14,
        15]
    }],
    "ENTITIES": [{
        "RESOLVED_ENTITY": {
            "ENTITY_ID": 9,
            "LENS_ID": 1,
            "ENTITY_NAME": "",
            "FEATURES": {
                "DRLIC": [{
                    "FEAT_DESC": "DL5473526 NV",
                    "LIB_FEAT_ID": 60,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "DL5473526 NV",
                        "LIB_FEAT_ID": 60
                    }]
                }],
                "PASSPORT": [{
                    "FEAT_DESC": "PP4444777 US",
                    "LIB_FEAT_ID": 61,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "PP4444777 US",
                        "LIB_FEAT_ID": 61
                    }]
                }]
            },
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.160",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.160"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.160",
            "RECORDS": [{
                "JSON_DATA": {
                    "CELL_PHONE_NUMBER": "",
                    "DATA_SOURCE": "PEOPLE",
                    "DATE_OF_BIRTH": "",
                    "DRIVERS_LICENSE_NUMBER": "DL5473526",
                    "DRIVERS_LICENSE_STATE": "NV",
                    "DSRC_ACTION": "A",
                    "EMAIL_ADDRESS": "",
                    "ENTITY_TYPE": "PEOPLE",
                    "GENDER": "",
                    "HOME_ADDR_CITY": "",
                    "HOME_ADDR_COUNTRY": "",
                    "HOME_ADDR_LINE1": "",
                    "HOME_ADDR_LINE2": "",
                    "HOME_ADDR_LINE3": "",
                    "HOME_ADDR_POSTAL_CODE": "",
                    "HOME_ADDR_STATE": "",
                    "LOAD_ID": "sample_person.csv",
                    "MAIL_ADDR_CITY": "",
                    "MAIL_ADDR_COUNTRY": "",
                    "MAIL_ADDR_LINE1": "",
                    "MAIL_ADDR_LINE2": "",
                    "MAIL_ADDR_LINE3": "",
                    "MAIL_ADDR_POSTAL_CODE": "",
                    "MAIL_ADDR_STATE": "",
                    "NIN_COUNTRY": "",
                    "NIN_NUMBER": "",
                    "PASSPORT_COUNTRY": "US",
                    "PASSPORT_NUMBER": "PP4444777",
                    "PRIMARY_NAME_FIRST": "",
                    "PRIMARY_NAME_LAST": "",
                    "PRIMARY_NAME_MIDDLE": "",
                    "PRIMARY_NAME_PREFIX": "",
                    "PRIMARY_NAME_SUFFIX": "",
                    "RECORD_ID": "1501",
                    "SOCIAL_HANDLE": "",
                    "SOCIAL_NETWORK": "",
                    "SSN_NUMBER": "",
                    "WORK_PHONE_NUMBER": ""
                },
                "DATA_SOURCE": "PEOPLE",
                "ENTITY_TYPE": "PEOPLE",
                "ENTITY_KEY": "1CD1FE71E3BDDB38AD33626561E2617605BAAE5A",
                "ENTITY_NAME": "",
                "RECORD_ID": "1501",
                "MATCH_KEY": "",
                "MATCH_SCORE": "",
                "ERRULE_CODE": "",
                "REF_SCORE": 0,
                "MATCH_LEVEL": 0,
                "LAST_SEEN_DT": "2019-03-01 01:42:23.160",
                "NAME_DATA": [],
                "ATTRIBUTE_DATA": [],
                "IDENTIFIER_DATA": ["DRLIC: DL5473526 NV",
                "PASSPORT: PP4444777 US"],
                "ADDRESS_DATA": [],
                "PHONE_DATA": [],
                "RELATIONSHIP_DATA": [],
                "ENTITY_DATA": [],
                "OTHER_DATA": []
            }]
        },
        "RELATED_ENTITIES": [{
            "ENTITY_ID": 10,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+PASSPORT-DRLIC",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.164",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.164"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.164"
        }]
    },
    {
        "RESOLVED_ENTITY": {
            "ENTITY_ID": 10,
            "LENS_ID": 1,
            "ENTITY_NAME": "",
            "FEATURES": {
                "DRLIC": [{
                    "FEAT_DESC": "DL5559999 NV",
                    "LIB_FEAT_ID": 64,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "DL5559999 NV",
                        "LIB_FEAT_ID": 64
                    }]
                }],
                "PASSPORT": [{
                    "FEAT_DESC": "PP4444777 US",
                    "LIB_FEAT_ID": 61,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "PP4444777 US",
                        "LIB_FEAT_ID": 61
                    }]
                }]
            },
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.164",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.164"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.164",
            "RECORDS": [{
                "JSON_DATA": {
                    "CELL_PHONE_NUMBER": "",
                    "DATA_SOURCE": "PEOPLE",
                    "DATE_OF_BIRTH": "",
                    "DRIVERS_LICENSE_NUMBER": "DL5559999",
                    "DRIVERS_LICENSE_STATE": "NV",
                    "DSRC_ACTION": "A",
                    "EMAIL_ADDRESS": "",
                    "ENTITY_TYPE": "PEOPLE",
                    "GENDER": "",
                    "HOME_ADDR_CITY": "",
                    "HOME_ADDR_COUNTRY": "",
                    "HOME_ADDR_LINE1": "",
                    "HOME_ADDR_LINE2": "",
                    "HOME_ADDR_LINE3": "",
                    "HOME_ADDR_POSTAL_CODE": "",
                    "HOME_ADDR_STATE": "",
                    "LOAD_ID": "sample_person.csv",
                    "MAIL_ADDR_CITY": "",
                    "MAIL_ADDR_COUNTRY": "",
                    "MAIL_ADDR_LINE1": "",
                    "MAIL_ADDR_LINE2": "",
                    "MAIL_ADDR_LINE3": "",
                    "MAIL_ADDR_POSTAL_CODE": "",
                    "MAIL_ADDR_STATE": "",
                    "NIN_COUNTRY": "",
                    "NIN_NUMBER": "",
                    "PASSPORT_COUNTRY": "US",
                    "PASSPORT_NUMBER": "PP4444777",
                    "PRIMARY_NAME_FIRST": "",
                    "PRIMARY_NAME_LAST": "",
                    "PRIMARY_NAME_MIDDLE": "",
                    "PRIMARY_NAME_PREFIX": "",
                    "PRIMARY_NAME_SUFFIX": "",
                    "RECORD_ID": "1502",
                    "SOCIAL_HANDLE": "",
                    "SOCIAL_NETWORK": "",
                    "SSN_NUMBER": "",
                    "WORK_PHONE_NUMBER": ""
                },
                "DATA_SOURCE": "PEOPLE",
                "ENTITY_TYPE": "PEOPLE",
                "ENTITY_KEY": "B191ABC8BD8592B55A1791E79B16ACA6B9F8603B",
                "ENTITY_NAME": "",
                "RECORD_ID": "1502",
                "MATCH_KEY": "",
                "MATCH_SCORE": "",
                "ERRULE_CODE": "",
                "REF_SCORE": 0,
                "MATCH_LEVEL": 0,
                "LAST_SEEN_DT": "2019-03-01 01:42:23.164",
                "NAME_DATA": [],
                "ATTRIBUTE_DATA": [],
                "IDENTIFIER_DATA": ["DRLIC: DL5559999 NV",
                "PASSPORT: PP4444777 US"],
                "ADDRESS_DATA": [],
                "PHONE_DATA": [],
                "RELATIONSHIP_DATA": [],
                "ENTITY_DATA": [],
                "OTHER_DATA": []
            }]
        },
        "RELATED_ENTITIES": [{
            "ENTITY_ID": 9,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+PASSPORT-DRLIC",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.160",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.160"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.160"
        },
        {
            "ENTITY_ID": 11,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+DRLIC-PASSPORT",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.168",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.168"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.168"
        }]
    },
    {
        "RESOLVED_ENTITY": {
            "ENTITY_ID": 11,
            "LENS_ID": 1,
            "ENTITY_NAME": "",
            "FEATURES": {
                "DRLIC": [{
                    "FEAT_DESC": "DL5559999 NV",
                    "LIB_FEAT_ID": 64,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "DL5559999 NV",
                        "LIB_FEAT_ID": 64
                    }]
                }],
                "PASSPORT": [{
                    "FEAT_DESC": "PP9984564 US",
                    "LIB_FEAT_ID": 67,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "PP9984564 US",
                        "LIB_FEAT_ID": 67
                    }]
                }],
                "SSN": [{
                    "FEAT_DESC": "425-23-3242",
                    "LIB_FEAT_ID": 66,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "425-23-3242",
                        "LIB_FEAT_ID": 66
                    }]
                }]
            },
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.168",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.168"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.168",
            "RECORDS": [{
                "JSON_DATA": {
                    "CELL_PHONE_NUMBER": "",
                    "DATA_SOURCE": "PEOPLE",
                    "DATE_OF_BIRTH": "",
                    "DRIVERS_LICENSE_NUMBER": "DL5559999",
                    "DRIVERS_LICENSE_STATE": "NV",
                    "DSRC_ACTION": "A",
                    "EMAIL_ADDRESS": "",
                    "ENTITY_TYPE": "PEOPLE",
                    "GENDER": "",
                    "HOME_ADDR_CITY": "",
                    "HOME_ADDR_COUNTRY": "",
                    "HOME_ADDR_LINE1": "",
                    "HOME_ADDR_LINE2": "",
                    "HOME_ADDR_LINE3": "",
                    "HOME_ADDR_POSTAL_CODE": "",
                    "HOME_ADDR_STATE": "",
                    "LOAD_ID": "sample_person.csv",
                    "MAIL_ADDR_CITY": "",
                    "MAIL_ADDR_COUNTRY": "",
                    "MAIL_ADDR_LINE1": "",
                    "MAIL_ADDR_LINE2": "",
                    "MAIL_ADDR_LINE3": "",
                    "MAIL_ADDR_POSTAL_CODE": "",
                    "MAIL_ADDR_STATE": "",
                    "NIN_COUNTRY": "",
                    "NIN_NUMBER": "",
                    "PASSPORT_COUNTRY": "US",
                    "PASSPORT_NUMBER": "PP9984564",
                    "PRIMARY_NAME_FIRST": "",
                    "PRIMARY_NAME_LAST": "",
                    "PRIMARY_NAME_MIDDLE": "",
                    "PRIMARY_NAME_PREFIX": "",
                    "PRIMARY_NAME_SUFFIX": "",
                    "RECORD_ID": "1503",
                    "SOCIAL_HANDLE": "",
                    "SOCIAL_NETWORK": "",
                    "SSN_NUMBER": "425-23-3242",
                    "WORK_PHONE_NUMBER": ""
                },
                "DATA_SOURCE": "PEOPLE",
                "ENTITY_TYPE": "PEOPLE",
                "ENTITY_KEY": "B879D5E07F5DEEA0170274F8EE4F4D7F2A73D8D4",
                "ENTITY_NAME": "",
                "RECORD_ID": "1503",
                "MATCH_KEY": "",
                "MATCH_SCORE": "",
                "ERRULE_CODE": "",
                "REF_SCORE": 0,
                "MATCH_LEVEL": 0,
                "LAST_SEEN_DT": "2019-03-01 01:42:23.168",
                "NAME_DATA": [],
                "ATTRIBUTE_DATA": [],
                "IDENTIFIER_DATA": ["DRLIC: DL5559999 NV",
                "PASSPORT: PP9984564 US",
                "SSN: 425-23-3242"],
                "ADDRESS_DATA": [],
                "PHONE_DATA": [],
                "RELATIONSHIP_DATA": [],
                "ENTITY_DATA": [],
                "OTHER_DATA": []
            }]
        },
        "RELATED_ENTITIES": [{
            "ENTITY_ID": 10,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+DRLIC-PASSPORT",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.164",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.164"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.164"
        },
        {
            "ENTITY_ID": 12,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+PASSPORT-DRLIC",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.173",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.173"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.173"
        },
        {
            "ENTITY_ID": 15,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+SSN-DRLIC-PASSPORT",
            "MATCH_SCORE": "4",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "COMPANIES",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.189",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.189"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.189"
        }]
    },
    {
        "RESOLVED_ENTITY": {
            "ENTITY_ID": 12,
            "LENS_ID": 1,
            "ENTITY_NAME": "",
            "FEATURES": {
                "DRLIC": [{
                    "FEAT_DESC": "DL7837747 NV",
                    "LIB_FEAT_ID": 70,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "DL7837747 NV",
                        "LIB_FEAT_ID": 70
                    }]
                }],
                "PASSPORT": [{
                    "FEAT_DESC": "PP9984564 US",
                    "LIB_FEAT_ID": 67,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "PP9984564 US",
                        "LIB_FEAT_ID": 67
                    }]
                }]
            },
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.173",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.173"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.173",
            "RECORDS": [{
                "JSON_DATA": {
                    "CELL_PHONE_NUMBER": "",
                    "DATA_SOURCE": "PEOPLE",
                    "DATE_OF_BIRTH": "",
                    "DRIVERS_LICENSE_NUMBER": "DL7837747",
                    "DRIVERS_LICENSE_STATE": "NV",
                    "DSRC_ACTION": "A",
                    "EMAIL_ADDRESS": "",
                    "ENTITY_TYPE": "PEOPLE",
                    "GENDER": "",
                    "HOME_ADDR_CITY": "",
                    "HOME_ADDR_COUNTRY": "",
                    "HOME_ADDR_LINE1": "",
                    "HOME_ADDR_LINE2": "",
                    "HOME_ADDR_LINE3": "",
                    "HOME_ADDR_POSTAL_CODE": "",
                    "HOME_ADDR_STATE": "",
                    "LOAD_ID": "sample_person.csv",
                    "MAIL_ADDR_CITY": "",
                    "MAIL_ADDR_COUNTRY": "",
                    "MAIL_ADDR_LINE1": "",
                    "MAIL_ADDR_LINE2": "",
                    "MAIL_ADDR_LINE3": "",
                    "MAIL_ADDR_POSTAL_CODE": "",
                    "MAIL_ADDR_STATE": "",
                    "NIN_COUNTRY": "",
                    "NIN_NUMBER": "",
                    "PASSPORT_COUNTRY": "US",
                    "PASSPORT_NUMBER": "PP9984564",
                    "PRIMARY_NAME_FIRST": "",
                    "PRIMARY_NAME_LAST": "",
                    "PRIMARY_NAME_MIDDLE": "",
                    "PRIMARY_NAME_PREFIX": "",
                    "PRIMARY_NAME_SUFFIX": "",
                    "RECORD_ID": "1504",
                    "SOCIAL_HANDLE": "",
                    "SOCIAL_NETWORK": "",
                    "SSN_NUMBER": "",
                    "WORK_PHONE_NUMBER": ""
                },
                "DATA_SOURCE": "PEOPLE",
                "ENTITY_TYPE": "PEOPLE",
                "ENTITY_KEY": "D2F995CC4222EB3B3AE1E61C446DA8554DE28D89",
                "ENTITY_NAME": "",
                "RECORD_ID": "1504",
                "MATCH_KEY": "",
                "MATCH_SCORE": "",
                "ERRULE_CODE": "",
                "REF_SCORE": 0,
                "MATCH_LEVEL": 0,
                "LAST_SEEN_DT": "2019-03-01 01:42:23.173",
                "NAME_DATA": [],
                "ATTRIBUTE_DATA": [],
                "IDENTIFIER_DATA": ["DRLIC: DL7837747 NV",
                "PASSPORT: PP9984564 US"],
                "ADDRESS_DATA": [],
                "PHONE_DATA": [],
                "RELATIONSHIP_DATA": [],
                "ENTITY_DATA": [],
                "OTHER_DATA": []
            }]
        },
        "RELATED_ENTITIES": [{
            "ENTITY_ID": 11,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+PASSPORT-DRLIC",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.168",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.168"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.168"
        },
        {
            "ENTITY_ID": 13,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+DRLIC-PASSPORT",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.178",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.178"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.178"
        }]
    },
    {
        "RESOLVED_ENTITY": {
            "ENTITY_ID": 13,
            "LENS_ID": 1,
            "ENTITY_NAME": "",
            "FEATURES": {
                "DRLIC": [{
                    "FEAT_DESC": "DL7837747 NV",
                    "LIB_FEAT_ID": 70,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "DL7837747 NV",
                        "LIB_FEAT_ID": 70
                    }]
                }],
                "PASSPORT": [{
                    "FEAT_DESC": "PP9683646 US",
                    "LIB_FEAT_ID": 72,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "PP9683646 US",
                        "LIB_FEAT_ID": 72
                    }]
                }]
            },
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.178",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.178"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.178",
            "RECORDS": [{
                "JSON_DATA": {
                    "CELL_PHONE_NUMBER": "",
                    "DATA_SOURCE": "PEOPLE",
                    "DATE_OF_BIRTH": "",
                    "DRIVERS_LICENSE_NUMBER": "DL7837747",
                    "DRIVERS_LICENSE_STATE": "NV",
                    "DSRC_ACTION": "A",
                    "EMAIL_ADDRESS": "",
                    "ENTITY_TYPE": "PEOPLE",
                    "GENDER": "",
                    "HOME_ADDR_CITY": "",
                    "HOME_ADDR_COUNTRY": "",
                    "HOME_ADDR_LINE1": "",
                    "HOME_ADDR_LINE2": "",
                    "HOME_ADDR_LINE3": "",
                    "HOME_ADDR_POSTAL_CODE": "",
                    "HOME_ADDR_STATE": "",
                    "LOAD_ID": "sample_person.csv",
                    "MAIL_ADDR_CITY": "",
                    "MAIL_ADDR_COUNTRY": "",
                    "MAIL_ADDR_LINE1": "",
                    "MAIL_ADDR_LINE2": "",
                    "MAIL_ADDR_LINE3": "",
                    "MAIL_ADDR_POSTAL_CODE": "",
                    "MAIL_ADDR_STATE": "",
                    "NIN_COUNTRY": "",
                    "NIN_NUMBER": "",
                    "PASSPORT_COUNTRY": "US",
                    "PASSPORT_NUMBER": "PP9683646",
                    "PRIMARY_NAME_FIRST": "",
                    "PRIMARY_NAME_LAST": "",
                    "PRIMARY_NAME_MIDDLE": "",
                    "PRIMARY_NAME_PREFIX": "",
                    "PRIMARY_NAME_SUFFIX": "",
                    "RECORD_ID": "1505",
                    "SOCIAL_HANDLE": "",
                    "SOCIAL_NETWORK": "",
                    "SSN_NUMBER": "",
                    "WORK_PHONE_NUMBER": ""
                },
                "DATA_SOURCE": "PEOPLE",
                "ENTITY_TYPE": "PEOPLE",
                "ENTITY_KEY": "42BC48A37138228ACDF30D34A9B84CD7FA3294F0",
                "ENTITY_NAME": "",
                "RECORD_ID": "1505",
                "MATCH_KEY": "",
                "MATCH_SCORE": "",
                "ERRULE_CODE": "",
                "REF_SCORE": 0,
                "MATCH_LEVEL": 0,
                "LAST_SEEN_DT": "2019-03-01 01:42:23.178",
                "NAME_DATA": [],
                "ATTRIBUTE_DATA": [],
                "IDENTIFIER_DATA": ["DRLIC: DL7837747 NV",
                "PASSPORT: PP9683646 US"],
                "ADDRESS_DATA": [],
                "PHONE_DATA": [],
                "RELATIONSHIP_DATA": [],
                "ENTITY_DATA": [],
                "OTHER_DATA": []
            }]
        },
        "RELATED_ENTITIES": [{
            "ENTITY_ID": 12,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+DRLIC-PASSPORT",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.173",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.173"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.173"
        },
        {
            "ENTITY_ID": 14,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+PASSPORT-DRLIC",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.184",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.184"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.184"
        }]
    },
    {
        "RESOLVED_ENTITY": {
            "ENTITY_ID": 14,
            "LENS_ID": 1,
            "ENTITY_NAME": "",
            "FEATURES": {
                "DRLIC": [{
                    "FEAT_DESC": "DL5463473 NV",
                    "LIB_FEAT_ID": 74,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "DL5463473 NV",
                        "LIB_FEAT_ID": 74
                    }]
                }],
                "PASSPORT": [{
                    "FEAT_DESC": "PP9683646 US",
                    "LIB_FEAT_ID": 72,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "PP9683646 US",
                        "LIB_FEAT_ID": 72
                    }]
                }]
            },
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.184",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.184"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.184",
            "RECORDS": [{
                "JSON_DATA": {
                    "CELL_PHONE_NUMBER": "",
                    "DATA_SOURCE": "PEOPLE",
                    "DATE_OF_BIRTH": "",
                    "DRIVERS_LICENSE_NUMBER": "DL5463473",
                    "DRIVERS_LICENSE_STATE": "NV",
                    "DSRC_ACTION": "A",
                    "EMAIL_ADDRESS": "",
                    "ENTITY_TYPE": "PEOPLE",
                    "GENDER": "",
                    "HOME_ADDR_CITY": "",
                    "HOME_ADDR_COUNTRY": "",
                    "HOME_ADDR_LINE1": "",
                    "HOME_ADDR_LINE2": "",
                    "HOME_ADDR_LINE3": "",
                    "HOME_ADDR_POSTAL_CODE": "",
                    "HOME_ADDR_STATE": "",
                    "LOAD_ID": "sample_person.csv",
                    "MAIL_ADDR_CITY": "",
                    "MAIL_ADDR_COUNTRY": "",
                    "MAIL_ADDR_LINE1": "",
                    "MAIL_ADDR_LINE2": "",
                    "MAIL_ADDR_LINE3": "",
                    "MAIL_ADDR_POSTAL_CODE": "",
                    "MAIL_ADDR_STATE": "",
                    "NIN_COUNTRY": "",
                    "NIN_NUMBER": "",
                    "PASSPORT_COUNTRY": "US",
                    "PASSPORT_NUMBER": "PP9683646",
                    "PRIMARY_NAME_FIRST": "",
                    "PRIMARY_NAME_LAST": "",
                    "PRIMARY_NAME_MIDDLE": "",
                    "PRIMARY_NAME_PREFIX": "",
                    "PRIMARY_NAME_SUFFIX": "",
                    "RECORD_ID": "1506",
                    "SOCIAL_HANDLE": "",
                    "SOCIAL_NETWORK": "",
                    "SSN_NUMBER": "",
                    "WORK_PHONE_NUMBER": ""
                },
                "DATA_SOURCE": "PEOPLE",
                "ENTITY_TYPE": "PEOPLE",
                "ENTITY_KEY": "A8766D53B07C82C649EBFED73E80184762A7552C",
                "ENTITY_NAME": "",
                "RECORD_ID": "1506",
                "MATCH_KEY": "",
                "MATCH_SCORE": "",
                "ERRULE_CODE": "",
                "REF_SCORE": 0,
                "MATCH_LEVEL": 0,
                "LAST_SEEN_DT": "2019-03-01 01:42:23.184",
                "NAME_DATA": [],
                "ATTRIBUTE_DATA": [],
                "IDENTIFIER_DATA": ["DRLIC: DL5463473 NV",
                "PASSPORT: PP9683646 US"],
                "ADDRESS_DATA": [],
                "PHONE_DATA": [],
                "RELATIONSHIP_DATA": [],
                "ENTITY_DATA": [],
                "OTHER_DATA": []
            }]
        },
        "RELATED_ENTITIES": [{
            "ENTITY_ID": 13,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+PASSPORT-DRLIC",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.178",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.178"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.178"
        },
        {
            "ENTITY_ID": 15,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+DRLIC-PASSPORT",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "COMPANIES",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.189",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.189"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.189"
        }]
    },
    {
        "RESOLVED_ENTITY": {
            "ENTITY_ID": 15,
            "LENS_ID": 1,
            "ENTITY_NAME": "",
            "FEATURES": {
                "DRLIC": [{
                    "FEAT_DESC": "DL5463473 NV",
                    "LIB_FEAT_ID": 74,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "DL5463473 NV",
                        "LIB_FEAT_ID": 74
                    }]
                }],
                "PASSPORT": [{
                    "FEAT_DESC": "PP3242342 US",
                    "LIB_FEAT_ID": 76,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "PP3242342 US",
                        "LIB_FEAT_ID": 76
                    }]
                }],
                "SSN": [{
                    "FEAT_DESC": "425-23-3242",
                    "LIB_FEAT_ID": 66,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "425-23-3242",
                        "LIB_FEAT_ID": 66
                    }]
                }]
            },
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "COMPANIES",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.189",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.189"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.189",
            "RECORDS": [{
                "JSON_DATA": {
                    "CELL_PHONE_NUMBER": "",
                    "DATA_SOURCE": "COMPANIES",
                    "DATE_OF_BIRTH": "",
                    "DRIVERS_LICENSE_NUMBER": "DL5463473",
                    "DRIVERS_LICENSE_STATE": "NV",
                    "DSRC_ACTION": "A",
                    "EMAIL_ADDRESS": "",
                    "ENTITY_TYPE": "COMPANIES",
                    "GENDER": "",
                    "HOME_ADDR_CITY": "",
                    "HOME_ADDR_COUNTRY": "",
                    "HOME_ADDR_LINE1": "",
                    "HOME_ADDR_LINE2": "",
                    "HOME_ADDR_LINE3": "",
                    "HOME_ADDR_POSTAL_CODE": "",
                    "HOME_ADDR_STATE": "",
                    "LOAD_ID": "sample_person.csv",
                    "MAIL_ADDR_CITY": "",
                    "MAIL_ADDR_COUNTRY": "",
                    "MAIL_ADDR_LINE1": "",
                    "MAIL_ADDR_LINE2": "",
                    "MAIL_ADDR_LINE3": "",
                    "MAIL_ADDR_POSTAL_CODE": "",
                    "MAIL_ADDR_STATE": "",
                    "NIN_COUNTRY": "",
                    "NIN_NUMBER": "",
                    "PASSPORT_COUNTRY": "US",
                    "PASSPORT_NUMBER": "PP3242342",
                    "PRIMARY_NAME_FIRST": "",
                    "PRIMARY_NAME_LAST": "",
                    "PRIMARY_NAME_MIDDLE": "",
                    "PRIMARY_NAME_PREFIX": "",
                    "PRIMARY_NAME_SUFFIX": "",
                    "RECORD_ID": "1507",
                    "SOCIAL_HANDLE": "",
                    "SOCIAL_NETWORK": "",
                    "SSN_NUMBER": "425-23-3242",
                    "WORK_PHONE_NUMBER": ""
                },
                "DATA_SOURCE": "COMPANIES",
                "ENTITY_TYPE": "COMPANIES",
                "ENTITY_KEY": "FA6D9C0B42C552FB36605EF21605679078192EEA",
                "ENTITY_NAME": "",
                "RECORD_ID": "1507",
                "MATCH_KEY": "",
                "MATCH_SCORE": "",
                "ERRULE_CODE": "",
                "REF_SCORE": 0,
                "MATCH_LEVEL": 0,
                "LAST_SEEN_DT": "2019-03-01 01:42:23.189",
                "NAME_DATA": [],
                "ATTRIBUTE_DATA": [],
                "IDENTIFIER_DATA": ["DRLIC: DL5463473 NV",
                "PASSPORT: PP3242342 US",
                "SSN: 425-23-3242"],
                "ADDRESS_DATA": [],
                "PHONE_DATA": [],
                "RELATIONSHIP_DATA": [],
                "ENTITY_DATA": [],
                "OTHER_DATA": []
            }]
        },
        "RELATED_ENTITIES": [{
            "ENTITY_ID": 11,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+SSN-DRLIC-PASSPORT",
            "MATCH_SCORE": "4",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.168",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.168"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.168"
        },
        {
            "ENTITY_ID": 14,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+DRLIC-PASSPORT",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.184",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.184"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.184"
        },
        {
            "ENTITY_ID": 16,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+PASSPORT-DRLIC",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.195",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.195"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.195"
        }]
    },
    {
        "RESOLVED_ENTITY": {
            "ENTITY_ID": 16,
            "LENS_ID": 1,
            "ENTITY_NAME": "",
            "FEATURES": {
                "DRLIC": [{
                    "FEAT_DESC": "DL0045747 NV",
                    "LIB_FEAT_ID": 78,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "DL0045747 NV",
                        "LIB_FEAT_ID": 78
                    }]
                }],
                "PASSPORT": [{
                    "FEAT_DESC": "PP3242342 US",
                    "LIB_FEAT_ID": 76,
                    "FEAT_DESC_VALUES": [{
                        "FEAT_DESC": "PP3242342 US",
                        "LIB_FEAT_ID": 76
                    }]
                }]
            },
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.195",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.195"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.195",
            "RECORDS": [{
                "JSON_DATA": {
                    "CELL_PHONE_NUMBER": "",
                    "DATA_SOURCE": "PEOPLE",
                    "DATE_OF_BIRTH": "",
                    "DRIVERS_LICENSE_NUMBER": "DL0045747",
                    "DRIVERS_LICENSE_STATE": "NV",
                    "DSRC_ACTION": "A",
                    "EMAIL_ADDRESS": "",
                    "ENTITY_TYPE": "PEOPLE",
                    "GENDER": "",
                    "HOME_ADDR_CITY": "",
                    "HOME_ADDR_COUNTRY": "",
                    "HOME_ADDR_LINE1": "",
                    "HOME_ADDR_LINE2": "",
                    "HOME_ADDR_LINE3": "",
                    "HOME_ADDR_POSTAL_CODE": "",
                    "HOME_ADDR_STATE": "",
                    "LOAD_ID": "sample_person.csv",
                    "MAIL_ADDR_CITY": "",
                    "MAIL_ADDR_COUNTRY": "",
                    "MAIL_ADDR_LINE1": "",
                    "MAIL_ADDR_LINE2": "",
                    "MAIL_ADDR_LINE3": "",
                    "MAIL_ADDR_POSTAL_CODE": "",
                    "MAIL_ADDR_STATE": "",
                    "NIN_COUNTRY": "",
                    "NIN_NUMBER": "",
                    "PASSPORT_COUNTRY": "US",
                    "PASSPORT_NUMBER": "PP3242342",
                    "PRIMARY_NAME_FIRST": "",
                    "PRIMARY_NAME_LAST": "",
                    "PRIMARY_NAME_MIDDLE": "",
                    "PRIMARY_NAME_PREFIX": "",
                    "PRIMARY_NAME_SUFFIX": "",
                    "RECORD_ID": "1508",
                    "SOCIAL_HANDLE": "",
                    "SOCIAL_NETWORK": "",
                    "SSN_NUMBER": "",
                    "WORK_PHONE_NUMBER": ""
                },
                "DATA_SOURCE": "PEOPLE",
                "ENTITY_TYPE": "PEOPLE",
                "ENTITY_KEY": "D06ECE67E582F2FFE6F8FC0F850CB21A7CFF54AB",
                "ENTITY_NAME": "",
                "RECORD_ID": "1508",
                "MATCH_KEY": "",
                "MATCH_SCORE": "",
                "ERRULE_CODE": "",
                "REF_SCORE": 0,
                "MATCH_LEVEL": 0,
                "LAST_SEEN_DT": "2019-03-01 01:42:23.195",
                "NAME_DATA": [],
                "ATTRIBUTE_DATA": [],
                "IDENTIFIER_DATA": ["DRLIC: DL0045747 NV",
                "PASSPORT: PP3242342 US"],
                "ADDRESS_DATA": [],
                "PHONE_DATA": [],
                "RELATIONSHIP_DATA": [],
                "ENTITY_DATA": [],
                "OTHER_DATA": []
            }]
        },
        "RELATED_ENTITIES": [{
            "ENTITY_ID": 15,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+PASSPORT-DRLIC",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "COMPANIES",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.189",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.189"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.189"
        },
        {
            "ENTITY_ID": 17,
            "LENS_ID": 1,
            "MATCH_LEVEL": 2,
            "MATCH_KEY": "+DRLIC-PASSPORT",
            "MATCH_SCORE": "3",
            "ERRULE_CODE": "SF1E",
            "REF_SCORE": 6,
            "IS_DISCLOSED": 0,
            "IS_AMBIGUOUS": 0,
            "ENTITY_NAME": "",
            "RECORD_SUMMARY": [{
                "DATA_SOURCE": "PEOPLE",
                "RECORD_COUNT": 1,
                "FIRST_SEEN_DT": "2019-03-01 01:42:23.199",
                "LAST_SEEN_DT": "2019-03-01 01:42:23.199"
            }],
            "LAST_SEEN_DT": "2019-03-01 01:42:23.199"
        }]
    }]
}

The FindNetworkByEntityIDV2() and FindNetworkByRecordIDV2() functions can be used to find all entities surrounding a requested set of entities. This includes the requested entities, paths between each pair of search entities, and relations to other nearby entities.

Entities can be searched for by either Entity ID or by Record ID, depending on which function is chosen.

These functions have the following parameters:

They also have various arguments used to return response documents.

The functions return a JSON document that identifies the path between each set of search entities (if the path exists), and the information on the entities in question (search entities, path entities, and build-out entities.)

For entity paths, an "ENTITY_PATHS" section of the result document will list the path found between each pair of entities in the input set. For example, if you search for three entities 10, 13, and 15, then it will produce paths from 10 to 13, 10 to 15, and 13 to 15. Each path that exists will be returned with the Entity IDs involved in a tag called "ENTITIES" (such as { "START_ENTITY_ID": 10, "END_ENTITY_ID": 15, "ENTITIES": [10, 11, 15] }). If no path exists, then the result will show an empty entity list (such as { "START_ENTITY_ID": 10, "END_ENTITY_ID": 13, "ENTITIES": [] } ).

The resulting document will also include a list of entities that are related to the searched entities. The full list of entities will be in ENTITIES section of the document, which gives the details about each individual entity. This will include all of the search entities and all of the entities found on the paths between search entities. Beyond that, it will return entities that are within the build-out-degree of relationships between the search entities. This last part will be limited by the cap of max entities, so as to prevent very large numbers of entities in the result document.

The functions FindNetworkByEntityIDV2() and FindNetworkByRecordIDV2() are improved versions of FindNetworkByEntityID() and FindNetworkByRecordID() that also allow you to use control flags. The FindNetworkByEntityID() and FindNetworkByRecordID() functions are deprecated.

Data Repository

Purge

Example code:

    engine.purgeRepository()
/** purgeRepository */
    int ret = engine.purgeRepository();

    System.out.println("PURGED Repository");

  int ret = G2_purgeRepository();
(g2) purgeRepository

To purge the G2 repository, use the aptly named purgeRepository() method.

Exceptions

Get Last Exception

Example code:

    # getLastException
    ret = engine.getLastException()

    # getLastExceptionCode
    ret2 = engine.getLastExceptionCode()
/** get last exception */
    string ret = engine.getLastException();

/** get last exception code */
    int ret2 = engine.getLastExceptionCode();
    char *response = NULL;
    size_t bufSize = 0;

    //getLastException
    int ret = G2Engine_getLastException(response, bufSize);

    //getLastExceptionCode
    int ret2 = G2Engine_getLastExceptionCode();

Both the getLastException() and the getLastExceptionCode() methods retrieve the last exception thrown in G2Engine -- the former returns the exception as a string, and the latter as an integer.

(Note: when using C, getLastException() accepts the following two parameters as input:

Clear Last Exception

Example code:

    # clearLastException
    engine.clearLastException()
    /** clear last exception */
    engine.clearLastException();
    G2Engine_clearLastException();

The clearLastException() method clears the last exception thrown in G2Engine.

Reference

Match Levels

The MATCH_LEVEL returned in the API response messages informs you of the high-level categorization of the match, discovered during entity resolution processing.

The match level categories are:

The match level can be used as a filter on API call response message results and reports for distilling, sorting and aggregating information.

Match Key

The MATCH_KEY returned in the API response messages describes the features that contributed to, or detracted from the match. A plus symbol (+) before a feature indicates it contributed to the match and a minus symbol (-) for features that detracted. A minus symbol is only displayed for exclusive features.

G2ConfigMgr

Config Manager

The G2ConfigMgr API is used to add specific JSON configurations to the database, so that they may be shared across remote systems. Such configurations are added to the database, and a configuration ID is created for each of them. The system may then be configured with a specific configuratin ID that points to one of those configurations. That configuration ID will then be the shared global config.

Initialization

Example code:

from G2ConfigMgr import G2ConfigMgr

#----------------------------------------
if __name__ == '__main__':
    moduleName = "pyG2"
    iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}"
    verboseLogging = False

    # Create the G2ConfigMgr object once per process
    configMgr = G2ConfigMgr()

    # Initialize the G2ConfigMgr object once per process. This will take a few seconds.
    ret = configMgr.initV2(moduleName, iniParams, verboseLogging)
import com.senzing.g2.engine.G2ConfigMgr;
import com.senzing.g2.engine.G2ConfigMgrJNI;

//...

    String G2_MODULE_NAME = "EngineSample";
    String iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}";
    boolean USE_VERBOSE_LOGGING = false;

//...

    G2ConfigMgr configMgr = new G2ConfigMgrJNI();
    int ret = configMgr.initV2(G2_MODULE_NAME, iniParams, USE_VERBOSE_LOGGING);
#include "libg2configmgr.h"
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argsz[])

{
    const char *moduleName = "g2config";
    const char *iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}";
    const int verboseLogging = 0;

    int ret = G2ConfigMgr_init_V2(moduleName, iniParams, verboseLogging);
}

cd /opt/senzing/g2/python
python G2Command.py

To start using G2ConfigMgr, you must first create and initialize an instance of the config manager. This should be done once per process.

Create a new instance of the config manager and assign it to a variable. Then, call the appropriate initialization method (such as initV2) to initialize the config manager.

During the call, the initialization methods accept the following parameters:

Calling these functions will return "0" upon success - useful for error handling.

Uninitialization

Example code:

   # When done with all requests in the process, shutdown the config manager
   configMgr.destroy()
/** destroy */
    int destroyResult = configMgr.destroy();
    int ret = G2ConfigMgr_destroy();
(g2) quit
Ending Terminal.

(g2) exit
Ending Terminal.

(g2) <CTRL-C>

Are you sure you want to exit?  yes
^C

Once all work is done in a given process, call destroy() to unitialize Senzing and clean up resources. You should always do this once at the end of each process.

Managing Configurations

Configuration JSON documents may be added to the datastore, so that they can be shared across remote systems.

Adding a Config

Example code:

    configStr = '{......a full JSON config document......}'
    configComments = 'Document with additional entity types from 12 Jan 2019.'
    configID = bytearray("")

    # add the config
    ret = configMgr.addConfig(configStr,configComments,configID)
    print str(response)
    String configStr = "{......a full JSON config document......}";
    String configComments = "Document with additional entity types from 12 Jan 2019.";
    Result<Long> configID = new Result<Long>();

    /** add the config */
    int ret = configMgr.addConfig(configStr, configComments, configID);
    System.out.println("CONFIG ID: " + configID.getValue());
    const char *configStr = "{......a full JSON config document......}";
    const char *configComments = "Document with additional entity types from 12 Jan 2019.";
    long long configID = 0;

    // add the config
    int ret = G2ConfigMgr_addConfig(configStr, configComments, &configID);
    printf("CONFIG ID: %lld\n", configID);
(g2) addConfigFile /opt/senzing/g2/data/g2config.json "Document with additional entity types from 12 Jan 2019."

Use addConfig() to add a configuration JSON document to the data repository.

The addConfig() function accepts the following parameters as input:

The function returns "0" upon success.

Getting a Config

Example code:

    configID = '123456'
    response = bytearray("")

    # get the config
    ret = configMgr.getConfig(configID,response)
    print str(response)
    long configID = 123456;
    StringBuffer response = new StringBuffer();

    /** get the config */
    int ret = configMgr.getConfig(configID,response);
    System.out.println(response.toString());
    const long long configID = 123456;
    char *response = NULL;
    size_t bufSize = 0;

    // Get the config
    int ret = G2ConfigMgr_getConfig(configID, &response, &bufSize, realloc);
    printf("Config Document: %s\n", response);
(g2) getConfig 123456

Use getConfig() to retrieve a specific configuration JSON document from the data repository.

The getConfig() function accepts the following parameters as input:

They also have various arguments used to return response documents.

The function returns "0" upon success.

Listing the known configs

Example code:

    response = bytearray("")

    # get the config
    ret = configMgr.getConfigList(response)
    print str(response)
    StringBuffer response = new StringBuffer();

    /** get the config */
    int ret = configMgr.getConfigList(response);
    System.out.println(response.toString());
    char *response = NULL;
    size_t bufSize = 0;

    //Get record
    int ret = G2ConfigMgr_getConfigList(&response, &bufSize, realloc);
    printf("Results: %s\n", response);
(g2) getConfigList

Example response:

{
    "CONFIGS": [{
        "CONFIG_ID": 3174562762,
        "CONFIG_COMMENTS": "Adding initial config",
        "SYS_CREATE_DT": "2019-06-21 17:28:23.868"
    },
    {
        "CONFIG_ID": 5628356827,
        "CONFIG_COMMENTS": "Revising config for business needs",
        "SYS_CREATE_DT": "2019-06-21 17:28:23.868"
    }]
}

Use getConfigList() to retrieve a list of the configuration JSON documents contained in the data repository.

The getConfigList() function has no input arguments, and various arguments used to return response documents.

The function returns "0" upon success.

Default Configurations

Multiple configuration JSON documents may be added to the datastore. Each of them may be referenced to start the engine and other API's with different configurations.

In order to specify that one of the configuration documents should be the global shared config, the config ID for that configuration document must be set as the default config ID.

Setting the default configuration

Example code:

    configID = 123456

    # add the config
    ret = configMgr.setDefaultConfigID(configID)
    long configID = 123456;

    /** set the default config */
    int ret = configMgr.setDefaultConfigID(configID);
    long long configID = 123456;

    // set the default config
    int ret = G2ConfigMgr_setDefaultConfigID(configID);
(g2) setDefaultConfigID 123456

Use setDefaultConfigID() to set the default configuration JSON document in the data repository.

The setDefaultConfigID() function accepts the following parameters as input:

The function returns "0" upon success.

Getting the default configuration

Example code:

    configID = bytearray("")

    # Get the default config ID
    ret = configMgr.getDefaultConfigID(configID)
    print str(configID)
    Result<Long> configID = new Result<Long>();

    /** Get the default config ID */
    int ret = configMgr.getDefaultConfigID(configID);
    System.out.println(configID.getValue());
    long long configID = 0;

    // Get the default config ID
    int ret = G2ConfigMgr_getDefaultConfigID(&configID);
    printf("Config Document: %lld\n", configID);
(g2) getDefaultConfigID

Use getDefaultConfigID() to retrieve a specific configuration JSON document from the data repository.

The getDefaultConfigID() function accepts the following parameters as input:

The function returns "0" upon success.

Exceptions

Get Last Exception

Example code:

    # getLastException
    ret = configMgr.getLastException()

    # getLastExceptionCode
    ret2 = configMgr.getLastExceptionCode()
/** get last exception */
    string ret = configMgr.getLastException();

/** get last exception code */
    int ret2 = configMgr.getLastExceptionCode();
    char *response = NULL;
    size_t bufSize = 0;

    //getLastException
    int ret = G2ConfigMgr_getLastException(response, bufSize);

    //getLastExceptionCode
    int ret2 = G2ConfigMgr_getLastExceptionCode();

Both the getLastException() and the getLastExceptionCode() methods retrieve the last exception thrown in G2ConfigMgr -- the former returns the exception as a string, and the latter as an integer.

(Note: when using C, getLastException() accepts the following two parameters as input:

Clear Last Exception

Example code:

    # clearLastException
    configMgr.clearLastException()
    /** clear last exception */
    configMgr.clearLastException();
    G2ConfigMgr_clearLastException();

The clearLastException() method clears the last exception thrown in G2ConfigMgr.

G2Config

Config

The G2Config API is used to create a new JSON configuration from the default template or manipulate a JSON configuration that it is provided. The API read/writes a JSON string, but that string would typically be read/written from/to a g2config.json file that the G2 engine reads during the init(...) call.

Initialization

Example code:

from G2Config import G2Config

#----------------------------------------
if __name__ == '__main__':
    moduleName = "pyG2"
    iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}"
    verboseLogging = False

    # Create the G2Config object with the G2Module.ini once per process
    config = G2Config()

    # Initialize the G2Config object once per process. This will take a few seconds.
    ret = config.initV2(moduleName, iniParams, verboseLogging)

import com.senzing.g2.engine.G2Config;
import com.senzing.g2.engine.G2ConfigJNI;

//...

    String moduleName = "G2JNI";
    String iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}";
    boolean verboseLogging = false;

/** init */
    G2Config config = new G2ConfigJNI();
    int initResult = config.initV2(moduleName, iniParams, verboseLogging);
#include "libg2config.h"
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argsz[])
{
    char *moduleName = "g2config";
    char *iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}";
    bool verboseLogging = false;
    int ret = G2Config_init_V2(moduleName, iniParams, verboseLogging);
}
cd /opt/senzing/g2/python
python G2Command.py

To start using G2Config, you must first create and initialize the G2Config object. This should be done once per process.

Create a new instance of the Senzing G2Config object and assign it to a variable. Then, call the appropriate initialization method (such as initV2) to initialize the G2Config object.

The G2Config_init function is deprecated. The version-2 functions (such as initV2) should be used instead.

During the call, the initialization methods accept the following parameters:

Calling these functions will return "0" upon success - useful for error handling.

Uninitialization

Example code:

    # Uninitialize
    config.destroy()
/** destroy */
    int destroyResult = config.destroy();
    int ret = G2Config_destroy();
This is not included in the command shell at this time.

The destroy() method will destroy and perform cleanup for the G2Config object. This method should be called once at the end of every process, once all other calls are complete.

Calling this function will return "0" upon success and "-1" if the G2 engine was not initialized.

Create

Example code:

    # Create
    configHandle = config.create()
/** create */
    long configHandle = config.create();
    // Create
    ConfigHandle configHandle = G2Config_create();
This is not included in the command shell at this time.

The create() method creates a stock Senzing JSON config from the template in %SUPPORTPATH%/g2config.json. Importantly, the create() method returns a long integer referred to here as a 'configHandle'. This 'configHandle' is a handle referring to the created Senzing configuration, and can be used to represent said Senzing configuration in later function calls (as will be shown below).

Load

Example code:

    # load
    jsonConfig = ""
    configHandle =  config.load(jsonConfig)
/** load */
    String jsonConfig = "";
    long configHandle =  config.load(jsonConfig);
    const char *jsonConfig = "";
    ConfigHandle configHandle = G2Config_load(jsonConfig);
This is not included in the command shell at this time.

The load() method initializes the G2Config object from a JSON string. Any time you need to edit an existing configuration from an existing repository, you will want to use this method to be able to modify it. Just as with create(), the load() method returns a 'configHandle', a long integer which can be used to refer to the loaded configuration in future function calls.

The load() method accepts one parameter:

Save

Example code:

    configHandle = config.create()
    response = bytearray("")

    # save
    ret = config.save(configHandle, response)
//...
    long configHandle = config.create();
    StringBuffer response = new StringBuffer();

//...

/** save */
    int ret = config.save(configHandle, response );
    ConfigHandle configHandle = G2Config_create();

    char *response = NULL;
    size_t bufSize = 0;

    int ret = G2Config_save(configHandle, &response, &bufSize, realloc);
This is not included in the command shell at this time.

The save() method saves the G2Config object into a JSON string. A program would typically save this into a file that is referenced in the G2 INI (e.g. G2Module.ini) as the G2CONFIGFILE. The save() method returns 0 upon success, and it accepts the following parameters:

Close

Example code:


    configHandle = config.create()

    # close
    config.close(configHandle)
//...
    long configHandle = config.create();

//...
/** close */
    config.close(configHandle);

    ConfigHandle configHandle = G2Config_create();

//...code body here...

    //Close config handle
    G2Config_close(configHandle);
This is not included in the command shell at this time.

The close() method cleans up the G2Config object pointed to by the given configHandle -- this should always be called once at the end of every process. The close() method accepts one parameter:

Add Data Source

Example code:


    configHandle = config.create()
    dataSourceCode = "CUSTOMER"

    # add data source
    ret = config.addDataSource(configHandle,dataSourceCode)

    # add data source with ID
    id = 0
    ret2 = config.addDataSourceWithID(configHandle,dataSourceCode, id)
//...
    long configHandle = config.create();
    String code = "CUSTOMER";

//...
/** add data source */
    int ret = config.addDataSource(configHandle, code);

/** add data source with ID */
    int id = 0;
    int ret2 = config.addDataSourceWithID(configHandle, code, id);

    ConfigHandle configHandle = G2Config_create();
    const char *dataSourceCode = "TEST";
    const int id = 1;

    //Add data source
    int ret = G2Config_addDataSource(configHandle, dataSourceCode);

    //Add data source with id
    int ret2 = G2Config_addDataSourceWithID(configHandle, dataSourceCode, id);
This is not included in the command shell at this time.

The addDataSource() method adds a data source with the given code (e.g. CUSTOMER, WATCHLIST, etc.) to the configuration and automatically assigns an appropriate unique ID. The addDataSource() method accepts two parameters:

The addDataSourceWithID() method is like the addDataSource() method, except that addDataSourceWithID() allows the user to specify which unique ID gets assigned above. If the id can't be assigned, the method will error. The addDataSourceWithID() method accepts three parameters:

Importantly, the addDataSourceWithID() method should only be used when an external system wants to manage the IDs, as reuse of the IDs will cause data integrity issues. The Senzing Workbench uses this mechanism, as it desires to maintain consistent IDs across multiple projects for potential future capabilities.

List Data Sources

Example code:


    configHandle = config.create()

    #List data sources
    response = bytearray("")
    ret = config.listDataSources(configHandle, response)
    print str(response)
//...
    long configHandle = config.create();

//...
/** list data sources */
    StringBuffer response = new StringBuffer();
    int ret = config.listDataSources(configHandle, response);

    System.out.println(response.toString());
//...
    ConfigHandle configHandle = G2Config_create();
    char *response = NULL;
    size_t bufSize = 0;
    const char *dataSourceCode = "TEST";

    int ret = G2Config_listDataSources(configHandle, &response, &bufSize, realloc);
    printf("%s\n", response);
This is not included in the command shell at this time.

Example response:

{"DSRC_CODE":["TEST","SEARCH","PEOPLE","COMPANIES","CUSTOMER"]}

The listDataSources() method returns a list of the G2Config object's current data sources as a JSON document to a user-designated string. The listDataSources() method returns a 0 upon success, and fails otherwise. The listDataSources() method accepts the following parameters:

Exceptions

Get Last Exception

Example code:

    # getLastException
    ret = config.getLastException()

    # getLastExceptionCode
    ret2 = engine.getLastExceptionCode()
/** get last exception */
    string ret = config.getLastException();

/** get last exception code */
    int ret2 = config.getLastExceptionCode();
    char *response = NULL;
    size_t bufSize = 0;

    //getLastException
    int ret = G2Config_getLastException(response, bufSize);

    //getLastExceptionCode
    int ret2 = G2Config_getLastExceptionCode();
This is not included in the command shell at this time.

Both the getLastException() and the getLastExceptionCode() methods retrieve the last exception thrown in G2Config -- the former returns the exception as a string, and the latter as an integer.

(Note: when using C, getLastException() accepts the following two parameters as input:

Clear Last Exception

Example code:

    # clearLastException
    config.clearLastException()
    /** clear last exception */
    config.clearLastException();
    G2Config_clearLastException();
This is not included in the command shell at this time.

The clearLastException() method clears the last exception thrown in G2Config.

G2Product

Product

The G2Product API is used to check version and license information.

Initialization

Example code:

from G2Product import G2Product

#----------------------------------------
if __name__ == '__main__':
    moduleName = "pyG2"
    iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}"
    verboseLogging = False

    # Create the G2Product object with the G2Module.ini once per process
    engine = G2Product()

    # Initialize the G2Product object once per process. This will take a few seconds.
    ret = engine.initV2(moduleName, iniParams, verboseLogging)
import com.senzing.g2.engine.G2Product;
import com.senzing.g2.engine.G2ProductJNI;

//...

    String moduleName = "G2ProductJNI";
    String iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}";
    boolean verboseLogging = false;

/** init */
    G2Product engine = new G2ProductJNI();
    int initResult = engine.initV2(moduleName, iniParams, verboseLogging);
#include "libg2product.h"
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argsz[])
{
    char *moduleName = "g2product";
    char *iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}";
    bool verboseLogging = false;
    int ret = G2Product_init_V2(moduleName, iniParams, verboseLogging);
}
cd /opt/senzing/g2/python
python G2Command.py

To start using G2Product, you must first create and initialize an instance of the object. This should be done once per process.

Create a new instance of the G2Product object and assign it to a variable. Then, call the appropriate initialization method (such as initV2) to initialize the engine.

The G2Product object is initialized/destroyed in the same manner as the G2Engine object. See the information under "G2Engine ==> Engine ==> Initialization" for more information about the different initialization functions, functional parameters, and so forth.

Uninitialization

Example code:

    # Uninitialize
    engine.destroy()
/** destroy */
    int destroyResult = engine.destroy();
    int ret = G2Product_destroy();
(g2) quit
Ending Terminal.

(g2) exit
Ending Terminal.

(g2) <CTRL-C>

Are you sure you want to exit?  yes
^C

The destroy() method will destroy and perform cleanup for the G2Product object. This method should be called once at the end of every process, once all other calls are complete.

Version Info

Example code:

     # Retrieve version details
     ret = engine.version()
     print ret
/** version */
    System.out.println("VERSION: " + engine.version());
    System.out.println("");
    printf("VERSION: %s\n", G2Product_version());
    version

Example response:

VERSION: {"COMPATIBILITY_VERSION":{"CONFIG_VERSION":"2"},"BUILD_DATE":"2019-02-26","VERSION":"1.6.19057","BUILD_NUMBER":"2019_02_26__17_52"}

Call version() to retrieve your Senzing engine version details. The call will return a JSON document containing all relevant version information.

License Info

Example code:

     # Retrieve license details
     ret = engine.license()
     print "LICENSE: "+ret

/** license */
    System.out.println("LICENSE: " + engine.license());
    System.out.println("");
    printf("LICENSE: %s\n", G2Product_license());
    license

Example response:

LICENSE: {"customer":"","contract":"","issueDate":"2018-06-19","licenseType":"EVAL","licenseLevel":"","billing":"","expireDate":"2018-12-19","recordLimit":10000}

Call license() to retrieve your Senzing engine license details. The call will return a JSON document containing all relevant license information.

License Validation

Example code:

     # Retrieve license details
     licenseFilePath = "/opt/senzing/g2/data/g2.lic"
     returnCode = engine.validateLicenseFile(licenseFilePath)
     if returnCode == 0:
          print "License validated."
     else:
          print "License validation failed."
/** license */
    String licenseFilePath = new String("/opt/senzing/g2/data/g2.lic");
    int returnCode = engine.validateLicenseFile(licenseFilePath);
    if (returnCode == 0)
        System.out.println("License validated.");
    else
        System.out.println("License validation failed.");
    const char* licenseFilePath = "/opt/senzing/g2/data/g2.lic";
    int returnCode = G2Product_validateLicenseFile(licenseFilePath);
    if (returnCode == 0)
        printf("License validated.");
    else
        printf("License validation failed.");
    validateLicenseFile /opt/senzing/g2/data/g2.lic

Example response:

License validated.

Call validateLicenseFile() to validate your Senzing engine license file. The call will return 0 if the license file is valid.

Exceptions

Get Last Exception

Example code:

    # getLastException
    ret = engine.getLastException()

    # getLastExceptionCode
    ret2 = engine.getLastExceptionCode()
/** get last exception */
    string ret = engine.getLastException();

/** get last exception code */
    int ret2 = engine.getLastExceptionCode();

    char *response = NULL;
    size_t bufSize = 0;

    //getLastException
    int ret = G2Product_getLastException(response, bufSize);

    //getLastExceptionCode
    int ret2 = G2Product_getLastExceptionCode();

Both the getLastException() and the getLastExceptionCode() methods retrieve the last exception thrown in G2Product -- the former returns the exception as a string, and the latter as an integer.

(Note: when using C, getLastException() accepts the following two parameters as input:

Clear Last Exception

Example code:

    # clearLastException
    engine.clearLastException()
    /** clear last exception */
    engine.clearLastException();
    G2Product_clearLastException();

The clearLastException() method clears the last exception thrown in G2Config.

G2Audit

The G2Audit API allows you to pull data reporting data back on how one data source is related to another. Once you are done loading one or more data sources, use this API to query information that can be useful for reporting, browsing, or auditing results.

The sections below provide an in-depth tutorial for the G2Audit API.

Initialization

Example code:

from G2Audit import G2Audit

#----------------------------------------
if __name__ == '__main__':
    moduleName = "pyG2"
    iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}"
    verboseLogging = False

    # Create the G2Audit object with the G2Module.ini once per process
    engine = G2Audit()

    # Initialize the G2Audit once per process. This will take a few seconds.
    initRet = engine.initV2(moduleName, iniParams, verboseLogging)
import com.senzing.g2.engine.G2Audit;
import com.senzing.g2.engine.G2AuditJNI;

//...

    String moduleName = "G2JNI";
    String iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}";
    boolean verboseLogging = false;

    /** initialize */
    G2Audit engine = new G2AuditJNI();
    int initResult = engine.initV2(moduleName, iniParams, verboseLogging);

#include "libg2audit.h"
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argsz[])
{
    char *moduleName = "g2module";
    char *iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}";
    bool verboseLogging = false;
    int ret = G2Audit_init_V2(moduleName, iniParams, verboseLogging);
}
cd /opt/senzing/g2/python
python G2Command.py

To start using the G2Audit, you must first create and initialize an instance of the G2Audit object. This should be done once per process.

Create a new instance of the G2Audit object and assign it to a variable. Then, call the appropriate initialization method (such as initV2) to initialize the auditor.

The G2Audit object is initialized/destroyed in the same manner as the G2Engine object. See the information under "G2Engine ==> Engine ==> Initialization" for more information about the different initialization functions, functional parameters, and so forth.

Uninitialization

Example code:

    # destroy
    engine.destroy()
/** destroy */
    int destroyResult = engine.destroy();
    int ret = G2Audit_destroy();
(g2) quit
Ending Terminal.

(g2) exit
Ending Terminal.

(g2) <CTRL-C>

Are you sure you want to exit?  yes
^C

The destroy() method will destroy and perform cleanup for the G2Audit object. This method should be called once at the end of every process, once all other calls are complete.

Open New Session

Example code:

    #openSession
    sessionHandle = engine.openSession()
/** create session handle */
    long sessionHandle = engine.openSession();
   SessionHandle sessionHandle = G2Audit_openSession();
This is not directly included in the command shell at this time.

The openSession() method returns a long integer referred to here as a 'sessionHandle'. This 'sessionHandle' is a handle referring to your G2Audit object, and can be used to represent said G2Audit object in later function calls (as will be shown below).

Cancel Session

Example code:

    #...
    sessionHandle = engine.openSession()

    #...body of code here...

    #cancelSession
    engine.cancelSession(sessionHandle)

//...
    long sessionHandle = engine.openSession();

//...body of code here...

/** cancelSession */
    engine.cancelSession(sessionHandle);

    SessionHandle sessionHandle = G2Audit_openSession();

    G2Audit_cancelSession(sessionHandle);
This is not directly included in the command shell at this time.

The cancelSession() method will “cancel” the generation of audit data associated with the given sessionHandle. This can be used to abort audit-related operations mid-process in another thread. The cancelSession() method accepts one parameter:

Close Session

Example code:

    #...
    sessionHandle = engine.openSession()

    #...body of code here...

    #closeSession
    engine.closeSession(sessionHandle)
//...
    long sessionHandle = engine.openSession();

//...body of code here...

/** closeSession */
    engine.closeSession(sessionHandle);

    SessionHandle sessionHandle = G2Audit_openSession();

    G2Audit_closeSession(sessionHandle);
This is not directly included in the command shell at this time.

The closeSession() method cleans up the G2Audit object pointed to by the given sessionHandle -- this should always be called once at the end of every process. The closeSession() method accepts one parameter:

Summary Data

Example code:

    sessionHandle = engine.openSession()

    response = bytearray("")
    response2 = bytearray("")

    #getSummaryData
    ret = engine.getSummaryData(sessionHandle, response)
    print "Summary data: "+str(response)

    #getSummaryDataDirect
    ret = engine.getSummaryDataDirect(response2)
    print "Summary data: "+str(response2)

    #...

    #close session when done
    engine.closeSession()
    long sessionHandle = engine.openSession();

    StringBuffer response = new StringBuffer();
    StringBuffer response2 = new StringBuffer();

/** getSummaryData */
    int ret = engine.getSummaryData(sessionHandle, response);
    System.out.println("Summary data: " + response.toString());

/** getSummaryDataDirect */
    int ret2 = engine.getSummaryDataDirect(response2);
    System.out.println("Summary data: " + response2.toString());

//...

/** close session when done */
    engine.closeSession();

    SessionHandle sessionHandle = G2Audit_openSession();

    char *response = NULL;
    char *response2 = NULL;
    size_t bufSize = 0;

    //Get summary data
    int ret = G2Audit_getSummaryData(sessionHandle, &response, &bufSize, realloc);
    printf("Summary data: %s\n", response);

    //Get summary data direct
    int ret2 = G2Audit_getSummaryDataDirect(&response2, &bufSize, realloc);
    printf("Summary data: %s\n", response2);

    //Close session when done
    G2Audit_closeSession(sessionHandle);
(g2) getSummaryData

(g2) getSummaryDataDirect

Example output:

{"SUMMARY_AUDIT_INFO":{"AUDIT_INFO":[{"FROM_DATA_SOURCE":"TEST","TO_DATA_SOURCE":"TEST","FROM_ENTITY_COUNT":1,"TO_ENTITY_COUNT":1,"FROM_SINGLE_COUNT":0,"TO_SINGLE_COUNT":0,"FROM_RECORD_COUNT":3,"TO_RECORD_COUNT":3,"MATCHED_COUNT":2,"MATCHED_ENTITY_COUNT":1,"POSSIBLE_MATCH_COUNT":0,"DISCOVERED_RELATIONSHIP_COUNT":0,"DISCLOSED_RELATIONSHIP_COUNT":0},{"FROM_DATA_SOURCE":"TEST","TO_DATA_SOURCE":"PEOPLE","FROM_ENTITY_COUNT":1,"TO_ENTITY_COUNT":3,"FROM_SINGLE_COUNT":0,"TO_SINGLE_COUNT":0,"FROM_RECORD_COUNT":3,"TO_RECORD_COUNT":4,"MATCHED_COUNT":0,"MATCHED_ENTITY_COUNT":0,"POSSIBLE_MATCH_COUNT":2,"DISCOVERED_RELATIONSHIP_COUNT":0,"DISCLOSED_RELATIONSHIP_COUNT":0},{"FROM_DATA_SOURCE":"TEST","TO_DATA_SOURCE":"COMPANIES","FROM_ENTITY_COUNT":1,"TO_ENTITY_COUNT":2,"FROM_SINGLE_COUNT":0,"TO_SINGLE_COUNT":0,"FROM_RECORD_COUNT":3,"TO_RECORD_COUNT":4,"MATCHED_COUNT":0,"MATCHED_ENTITY_COUNT":0,"POSSIBLE_MATCH_COUNT":0,"DISCOVERED_RELATIONSHIP_COUNT":0,"DISCLOSED_RELATIONSHIP_COUNT":0},{"FROM_DATA_SOURCE":"PEOPLE","TO_DATA_SOURCE":"TEST","FROM_ENTITY_COUNT":3,"TO_ENTITY_COUNT":1,"FROM_SINGLE_COUNT":0,"TO_SINGLE_COUNT":0,"FROM_RECORD_COUNT":4,"TO_RECORD_COUNT":3,"MATCHED_COUNT":0,"MATCHED_ENTITY_COUNT":0,"POSSIBLE_MATCH_COUNT":2,"DISCOVERED_RELATIONSHIP_COUNT":0,"DISCLOSED_RELATIONSHIP_COUNT":0},{"FROM_DATA_SOURCE":"PEOPLE","TO_DATA_SOURCE":"PEOPLE","FROM_ENTITY_COUNT":3,"TO_ENTITY_COUNT":3,"FROM_SINGLE_COUNT":0,"TO_SINGLE_COUNT":0,"FROM_RECORD_COUNT":4,"TO_RECORD_COUNT":4,"MATCHED_COUNT":1,"MATCHED_ENTITY_COUNT":1,"POSSIBLE_MATCH_COUNT":1,"DISCOVERED_RELATIONSHIP_COUNT":1,"DISCLOSED_RELATIONSHIP_COUNT":0},{"FROM_DATA_SOURCE":"PEOPLE","TO_DATA_SOURCE":"COMPANIES","FROM_ENTITY_COUNT":3,"TO_ENTITY_COUNT":2,"FROM_SINGLE_COUNT":0,"TO_SINGLE_COUNT":0,"FROM_RECORD_COUNT":4,"TO_RECORD_COUNT":4,"MATCHED_COUNT":0,"MATCHED_ENTITY_COUNT":0,"POSSIBLE_MATCH_COUNT":0,"DISCOVERED_RELATIONSHIP_COUNT":1,"DISCLOSED_RELATIONSHIP_COUNT":0},{"FROM_DATA_SOURCE":"COMPANIES","TO_DATA_SOURCE":"TEST","FROM_ENTITY_COUNT":2,"TO_ENTITY_COUNT":1,"FROM_SINGLE_COUNT":0,"TO_SINGLE_COUNT":0,"FROM_RECORD_COUNT":4,"TO_RECORD_COUNT":3,"MATCHED_COUNT":0,"MATCHED_ENTITY_COUNT":0,"POSSIBLE_MATCH_COUNT":0,"DISCOVERED_RELATIONSHIP_COUNT":0,"DISCLOSED_RELATIONSHIP_COUNT":0},{"FROM_DATA_SOURCE":"COMPANIES","TO_DATA_SOURCE":"PEOPLE","FROM_ENTITY_COUNT":2,"TO_ENTITY_COUNT":3,"FROM_SINGLE_COUNT":0,"TO_SINGLE_COUNT":0,"FROM_RECORD_COUNT":4,"TO_RECORD_COUNT":4,"MATCHED_COUNT":0,"MATCHED_ENTITY_COUNT":0,"POSSIBLE_MATCH_COUNT":0,"DISCOVERED_RELATIONSHIP_COUNT":1,"DISCLOSED_RELATIONSHIP_COUNT":0},{"FROM_DATA_SOURCE":"COMPANIES","TO_DATA_SOURCE":"COMPANIES","FROM_ENTITY_COUNT":2,"TO_ENTITY_COUNT":2,"FROM_SINGLE_COUNT":0,"TO_SINGLE_COUNT":0,"FROM_RECORD_COUNT":4,"TO_RECORD_COUNT":4,"MATCHED_COUNT":2,"MATCHED_ENTITY_COUNT":2,"POSSIBLE_MATCH_COUNT":0,"DISCOVERED_RELATIONSHIP_COUNT":0,"DISCLOSED_RELATIONSHIP_COUNT":0}]}}

The getSummaryData() method obtains general summary data about your current audit session, and sends this data in JSON form to a user-designated response string. The getSummaryData() method returns "0" upon success, and accepts the following parameters as input:

Alternatively, the getSummaryDataDirect() method behaves exactly as the previous method, but without the need for a predefined session handle. The getSummaryDataDirect() method returns "0" upon success, and accepts the following parameters as input:

Used Match Keys

Example code:

    sessionHandle = engine.openSession()

    response = bytearray("")
    fromDataSource = dataSourceCode  #i.e. fromDataSource = "TEST"
    toDataSource = dataSourceCode
    matchLevel = 1

    #getUsedMatchKeys
    ret = engine.getUsedMatchKeys(sessionHandle, fromDataSource, toDataSource, matchLevel, response)
    print str(response)

    #...

    #close session when done
    engine.closeSession()
    long sessionHandle = engine.openSession();

    StringBuffer response = new StringBuffer();
    string fromDataSource = dataSourceCode; //i.e. string fromDataSource = "TEST";
    string toDataSource = dataSourceCode;
    int matchLevel = 1;

/** getUsedMatchKeys */
    int ret = engine.getUsedMatchKeys(sessionHandle, fromDataSource, toDataSource, matchLevel, response);
    System.out.println(response.toString());

//...

/** close session when done */
    engine.closeSession();
    SessionHandle sessionHandle = G2Audit_openSession();

    char *response = NULL;
    size_t bufSize = 0;
    const char *fromDataSource = "TEST";
    const char *toDataSource = "TEST";
    const int match_level = 1;

    //getUsedMatchKeys
    int ret = G2Audit_getUsedMatchKeys(sessionHandle, fromDataSource, toDataSource, match_level, &response, &bufSize, realloc);
    printf("Used key data: %s\n", response);

    //close session when done
    G2Audit_closeSession(sessionHandle);
(g2) getUsedMatchKeys TEST TEST 1

Example output:

{"DISTINCT_MATCH_KEY_INFO":{"MATCH_KEY_INFO":[{"MATCH_KEY":"+NAME+DOB+ADDRESS+SSN","COUNT":1},{"MATCH_KEY":"EXACTLY_SAME","COUNT":1}]}}

The getUsedMatchKeys() method fetches the usage frequency of different match keys, and returns this information in JSON form to a user-designated string (the method itself returns '0' upon success) . The getUsedMatchKeys() method accepts the following parameters as input:

Used Principles

Example code:

    sessionHandle = engine.openSession()

    response = bytearray("")
    fromDataSource = dataSourceCode  #i.e. fromDataSource = "TEST"
    toDataSource = dataSourceCode
    matchLevel = 1

    #getUsedPrinciples
    ret = engine.getUsedPrinciples(sessionHandle, fromDataSource, toDataSource, matchLevel, response)
    print str(response)

    #...

    #close session when done
    engine.closeSession()
    long sessionHandle = engine.openSession();

    string fromDataSource = dataSourceCode; //i.e. string fromDataSource = "TEST";
    string toDataSource = dataSourceCode;
    int matchLevel = 1;
    StringBuffer response = new StringBuffer();

/** get used principles */
    int ret = engine.getUsedPrinciples(sessionHandle, fromDataSource, toDataSource, matchLevel, response);
    System.out.println(response.toString());

//...

/** close session when done */
    engine.closeSession();

    SessionHandle sessionHandle = G2Audit_openSession();

    char *response = NULL;
    size_t bufSize = 0;
    const char *fromDataSource = "TEST";
    const char *toDataSource = "TEST";
    const int match_level = 1;

    //getUsedPrinciples
    int ret = G2Audit_getUsedPrinciples(sessionHandle, fromDataSource, toDataSource, match_level, &response, &bufSize, realloc);
    printf("Used principle data: %s\n", response);

    //close session when done
    G2Audit_closeSession(sessionHandle);
(g2) getUsedPrinciples TEST TEST 1

Example output:

{"DISTINCT_PRINCIPLE_INFO":{"PRINCIPLE_INFO":[{"PRINCIPLE":"SF1_PNAME_CFF_CSTAB","COUNT":1}]}}

The getUsedPrinciples() method fetches the usage frequency of different entity resolution principles, and sends this information in JSON form to a user-designated string (the method itself returns '0' upon success) . The getUsedPrinciples() method accepts the following parameters as input:

Get Audit Report

Example code:

    #Preliminary parameters
    sessionHandle = engine.openSession()
    fromDataSource = dataSourceCode #i.e. fromDataSource = "TEST"
    toDataSource = dataSourceCode
    matchLevel = 1

    #getAuditReport
    reportHandle = engine.getAuditReport(sessionHandle,fromDataSource, toDataSource, matchLevel)

    #fetchNext
    response = engine.fetchNext(reportHandle)
    print "Fetched data: "+response

    #...

    #closeReport
    engine.closeReport(reportHandle)

    #...

    #closeSession
    engine.closeSession(sessionHandle)
//Preliminary parameters
    long sessionHandle = engine.openSession();
    string fromDataSource = dataSourceCode; //i.e. string fromDataSource = "TEST";
    string toDataSource = dataSourceCode;
    int matchLevel = 1;

//...

/** getAuditReport */
    long reportHandle = engine.getAuditReport(sessionHandle, toDataSource, fromDataSource, match_level);

/** fetchNext */
    String fetched = engine.fetchNext(reportHandle);
    System.out.println("Fetched data: " + fetched);

//...

/** closeReport */
    engine.closeReport(reportHandle);

//...

/** close session when done */
    engine.closeSession();

    //Preliminary parameter definitions
    SessionHandle sessionHandle = G2Audit_openSession();
    char response[64*1028];
    const char *fromDataSource = "TEST";
    const char *toDataSource = "TEST";
    const int match_level = 1;

    //getAuditReport
    ReportHandle reportHandle = G2Audit_getAuditReport(sessionHandle, fromDataSource, toDataSource, match_level);

    //fetchNext
    while (NULL != G2Audit_fetchNext(reportHandle, response, sizeof(response))) {
        printf("%s\n",response);
    }

    //closeReport
    G2Audit_closeReport(reportHandle);

(g2) getAuditReport -f TEST -t TEST -m 1

Example output:

{"AUDIT_PAGE":{"AUDIT_GROUPS":[{"BASE_RECORD":[{"ENTITY_ID":1,"PRINCIPLE":"","MATCH_KEY":"","RECORD_ID":"RECORD1","ENTITY_TYPE":"TEST","DATA_SOURCE":"TEST","MATCH_TYPE":0,"AUDIT_SCORE":"","REF_SCORE":0,"NAME_DATA":["PRIMARY: SMITH JOE H"],"ATTRIBUTE_DATA":["DOB: 1965-05-23"],"IDENTIFIER_DATA":["SSN: 345678999"],"ADDRESS_DATA":["HOME: 653 STATE ROUTE 7 FRESNO CA 55073"],"PHONE_DATA":[],"RELATIONSHIP_DATA":[],"ENTITY_DATA":[],"OTHER_DATA":["LENS: DEFAULT"]}],"AUDIT_RECORD":[{"ENTITY_ID":1,"PRINCIPLE":"SF1_PNAME_CFF_CSTAB","MATCH_KEY":"+NAME+DOB+ADDRESS+SSN","RECORD_ID":"RECORD2","ENTITY_TYPE":"TEST","DATA_SOURCE":"TEST","MATCH_TYPE":1,"AUDIT_SCORE":"17","REF_SCORE":10,"NAME_DATA":["PRIMARY: SMITH JOSEPH"],"ATTRIBUTE_DATA":["DOB: 1965-05-23"],"IDENTIFIER_DATA":["SSN: 345678999"],"ADDRESS_DATA":["HOME: 653 STATE ROUTE 7 FRESNO CA 55073-1234"],"PHONE_DATA":[],"RELATIONSHIP_DATA":[],"ENTITY_DATA":[],"OTHER_DATA":["LENS: DEFAULT"]}],"ECL_RECORD":[],"AUDIT_KEY":"1","AUDIT_NAME":"PRIMARY: SMITH JOSEPH","AUDIT_TYPE":"","FROM_DATA_SOURCE":"TEST","TO_DATA_SOURCE":"TEST"}],"FROM_DATA_SOURCE":"TEST","TO_DATA_SOURCE":"TEST","MATCH_LEVEL":1,"FIRST_RECORD_INDEX":0}}

There are three steps to auditing entity data from the G2Audit object. First, use the getAuditReport() method to generate a long integer, referred to here as a 'reportHandle'. The getAuditReport() method accepts four parameter as input:

Second, use the fetchNext() method to read the reportHandle and export a row of JSON output containing the audit data for a single resolved entity. Note that successive calls of fetchNext() will export successive rows of entity data. The fetchNext() method accepts the following parameters as input:

Finally, use the closeReport() method to close the reportHandle and clean up system resources. This should always be called once you are finished auditing resolved entity data. The closeReport() method accepts one parameter as input:

Exceptions

Get Last Exception

Example code:

    # getLastException
    ret = engine.getLastException()

    # getLastExceptionCode
    ret2 = engine.getLastExceptionCode()


/** get last exception */
    string ret = engine.getLastException();

/** get last exception code */
    int ret2 = engine.getLastExceptionCode();

    char *response = NULL;
    size_t bufSize = 0;

    //getLastException
    int ret = G2Audit_getLastException(response, bufSize);

    //getLastExceptionCode
    int ret2 = G2Audit_getLastExceptionCode();

Both the getLastException() and the getLastExceptionCode() methods retrieve the last exception thrown in G2Audit -- the former returns the exception as a string, and the latter as an integer.

(Note: when using C, getLastException() accepts the following two parameters as input:

Clear Last Exception

Example code:

    # clearLastException
    engine.clearLastException()
    /** clear last exception */
    engine.clearLastException();
    G2Audit_clearLastException();

The clearLastException() method clears the last exception thrown in G2Audit.

Getting Stuff Done

Adding and Removing Records with the Senzing Engine Interface

Overview

This article demonstrates the basic code:

from G2Engine import G2Engine

#----------------------------------------
if __name__ == '__main__':
    moduleName = "pyG2"
    iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}"
    verboseLogging = False

    # Create the G2Engine object with the G2Module.ini once per process
    engine = G2Engine()

    # Initialize the G2Engine once per process. This will take a few seconds.
    initRet = engine.initV2(moduleName, iniParams, verboseLogging)

    dataSourceCode = 'TEST'
    recordID = 'entity_record_id'
    jsonData = '{"NAMES": [{ "NAME_TYPE": "PRIMARY", "NAME_LAST": "Smith", "NAME_FIRST": "John", "NAME_MIDDLE": "M"}], "PASSPORT_NUMBER": "PP11111", "PASSPORT_COUNTRY": "US", "DRIVERS_LICENSE_NUMBER": "DL11111", "SSN_NUMBER": "111-11-1111" }'
    loadID = None

    # Add data record(s)
    # Make as many parallel requests as desired.
    ret = engine.addRecord(dataSourceCode,recordID,jsonData,loadID)

    jsonData2 =  "{\"NAME_TYPE\": \"PRIMARY\", \"NAME_FIRST\": \"JOHN\", \"NAME_LAST\": \"SMITH\", \"ADDR_TYPE\": \"HOME\", \"ADDR_LINE1\": \"653 STATE ROUTE 7\", \"ADDR_CITY\": \"FRESNO\", \"ADDR_STATE\": \"CA\", \"ADDR_POSTAL_CODE\": \"55073-1234\"}"


    #replaceRecord
    ret = engine.replaceRecord(dataSourceCode, recordID, jsonData2, loadID)


    #deleteRecord
    ret = engine.deleteRecord(dataSourceCode,recordID, loadID)

    #When done with all G2 requests, shut down the G2 Engine */
    engine.destroy()

import com.senzing.g2.engine.G2Engine;
import com.senzing.g2.engine.G2JNI;

//...

    String moduleName = "G2JNI";
    String iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}";
    boolean verboseLogging = false;

/** init */
    G2Engine engine = new G2JNI();
    int initResult = engine.initV2(moduleName, iniParams, verboseLogging);

    String dataSourceCode = "TEST";
    String recordID = "RECORD3";
    String jsonData =  "{\"NAME_TYPE\": \"PRIMARY\", \"NAME_FIRST\": \"JANE\", \"NAME_LAST\": \"SMITH\", \"ADDR_TYPE\": \"HOME\", \"ADDR_LINE1\": \"653 STATE ROUTE 7\", \"ADDR_CITY\": \"FRESNO\", \"ADDR_STATE\": \"CA\", \"ADDR_POSTAL_CODE\": \"55073-1234\"}";
    String loadID = null;

/** addRecord */
    int ret = engine.addRecord(dataSourceCode, recordID, jsonData, loadID);

    String jsonData2 =  "{\"NAME_TYPE\": \"PRIMARY\", \"NAME_FIRST\": \"JOHN\", \"NAME_LAST\": \"SMITH\", \"ADDR_TYPE\": \"HOME\", \"ADDR_LINE1\": \"653 STATE ROUTE 7\", \"ADDR_CITY\": \"FRESNO\", \"ADDR_STATE\": \"CA\", \"ADDR_POSTAL_CODE\": \"55073-1234\"}";


/** replaceRecord */
    ret = engine.replaceRecord(dataSourceCode, recordID, jsonData2, loadID);


/** deleteRecord */
    ret = engine.deleteRecord(dataSourceCode,recordID, loadID);

/** When done with all G2 requests, shut down the G2 Engine */
    int destroyResult = engine.destroy();

#include "libg2.h"
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argsz[])
{
    char *moduleName = "g2module";
    char *iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}";
    bool verboseLogging = false;

    //init
    int ret = G2_init_V2(moduleName, iniParams, verboseLogging);

    const char *dataSourceCode = "TEST";
    const char *recordID = "RECORD3";
    const char *jsonData =  "{\"NAME_TYPE\": \"PRIMARY\", \"NAME_FIRST\": \"JANE\", \"NAME_LAST\": \"SMITH\", \"ADDR_TYPE\": \"HOME\", \"ADDR_LINE1\": \"653 STATE ROUTE 7\", \"ADDR_CITY\": \"FRESNO\", \"ADDR_STATE\": \"CA\", \"ADDR_POSTAL_CODE\": \"55073-1234\"}";
    const char *loadID = NULL;

    //addRecord
    int ret2 = G2_addRecord(dataSourceCode, recordID, jsonData, loadID);

    const char *jsonData2 =  "{\"NAME_TYPE\": \"PRIMARY\", \"NAME_FIRST\": \"JANE\", \"NAME_LAST\": \"SMITH\", \"ADDR_TYPE\": \"HOME\", \"ADDR_LINE1\": \"653 STATE ROUTE 7\", \"ADDR_CITY\": \"FRESNO\", \"ADDR_STATE\": \"CA\", \"ADDR_POSTAL_CODE\": \"55073-1234\"}";

    //replaceRecord
    int ret3 = G2_replaceRecord(dataSourceCode, recordID, jsonData2, loadID);

    //deleteRecord
    int ret4 = G2_deleteRecord(dataSourceCode, recordID, loadID);

    //When done with all G2 requests, shut down the G2 Engine
    int destroyResult = G2_destroy();
}

Entity data can be easily loaded into the data repository through the use of the G2 engine interface. This allows for a more direct way of adding (or removing) data from an application system.

There is much background on the core of the JSON messages in the Generic Entity Specification article. This information can help to create the necessary JSON documents for specifying entity attributes.

With a few function calls, you can add data using a few key fields and a simple JSON document outlining the entity attributes.

Adding and Removing Records with G2 Engine

The three core steps for utilizing the G2 Engine to retrieve entity information are:

  1. Create and initialize a new G2Engine object with an arbitrary name and initialization parameters that the the G2Module.ini points to. There should be one G2Engine object per process.
  2. After the G2Engine object is initialized, addRecord(), replaceRecord(), and deleteRecord() can be called as many times as desired and from multiple threads at the same time.
  3. Once all function calls are complete, call destroy() to clean up resources.

Functional Parameters

The functional parameters for the functions to add/remove records are as follows…

Searching by Entity Attributes with the Senzing Engine Interface

Overview

This article demonstrates the basic code:

from G2Engine import G2Engine

#----------------------------------------
if __name__ == '__main__':
    moduleName = "pyG2"
    iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}"
    verboseLogging = False

    # Create the G2Engine object with the G2Module.ini once per process
    engine = G2Engine()

    # Initialize the G2Engine once per process. This will take a few seconds.
    initRet = engine.initV2(moduleName, iniParams, verboseLogging)

    jsonData = '{"NAMES": [{ "NAME_TYPE": "PRIMARY", "NAME_LAST": "Smith", "NAME_FIRST": "John", "NAME_MIDDLE": "M"}], "PASSPORT_NUMBER": "PP11111", "PASSPORT_COUNTRY": "US", "DRIVERS_LICENSE_NUMBER": "DL11111", "SSN_NUMBER": "111-11-1111" }'

    response = bytearray("")

    #searchByAttributes
    #make as many parallel requests as desired
    ret = engine.searchByAttributes(jsonData,response)
    print str(response)

    #When done with all G2 requests, shut down the G2 Engine
    engine.destroy()

import com.senzing.g2.engine.G2Engine;
import com.senzing.g2.engine.G2JNI;

//...

    String moduleName = "G2JNI";
    String iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}";
    boolean verboseLogging = false;

/** init */
    G2Engine engine = new G2JNI();
    int initResult = engine.initV2(moduleName, iniParams, verboseLogging);

    String jsonData =  "{\"NAME_TYPE\": \"PRIMARY\", \"NAME_FIRST\": \"JANE\", \"NAME_LAST\": \"SMITH\", \"ADDR_TYPE\": \"HOME\", \"ADDR_LINE1\": \"653 STATE ROUTE 7\", \"ADDR_CITY\": \"FRESNO\", \"ADDR_STATE\": \"CA\", \"ADDR_POSTAL_CODE\": \"55073-1234\"}";

    StringBuffer response = new StringBuffer();

/** searchByAttributes */
/** make as many parallel requests as desired */
    int ret = engine.searchByAttributes(jsonData, response);
    System.out.println("GET Entity: " + response.toString());

/** When done with all G2 requests, shut down the G2 Engine */
    int destroyResult = engine.destroy();

#include "libg2.h"
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argsz[])
{
    char *moduleName = "g2module";
    char *iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}";
    bool verboseLogging = false;

    //init
    int ret = G2_init_V2(moduleName, iniParams, verboseLogging);

    const char *jsonData =  "{\"NAME_TYPE\": \"PRIMARY\", \"NAME_FIRST\": \"JANE\", \"NAME_LAST\": \"SMITH\", \"ADDR_TYPE\": \"HOME\", \"ADDR_LINE1\": \"653 STATE ROUTE 7\", \"ADDR_CITY\": \"FRESNO\", \"ADDR_STATE\": \"CA\", \"ADDR_POSTAL_CODE\": \"55073-1234\"}";
    char *response = NULL;
    size_t bufSize = 0;

    //Search by entity attributes
    int ret2 = G2_searchByAttributes(jsonData, &response, &bufSize, realloc);
    printf("RECORD: %s\n", response);
    free(response);

    //When done with all G2 requests, shut down the G2 Engine
    int destroyResult = G2_destroy();
}

(g2) searchByAttributes <jsonData>

Entity searching is a key component for interactive use of Entity Resolution intelligence. The core Senzing G2 engine provides real-time search capabilities that are easily accessed via the available G2Engine.py interface. The system can be searched for a profile of attributes.

There is much background on the core of the JSON messages in the Generic Entity Specification article. This information can help to create the necessary JSON documents for specifying entity attributes.

With a few function calls, you can search for entities using a simple JSON document outlining the entity attributes.

Searching for Attributes with the Senzing Engine

The three core steps for utilizing the G2 Engine to retrieve entity information are:

  1. Create and initialize a new G2Engine object with an arbitrary name and the G2Module.ini that the G2Project.ini points to. There should be one G2Engine object per process.
  2. After the G2Engine object is initialized, searchByAttributes() can be called as many times as desired and from multiple threads at the same time.
  3. Once all function calls are complete, call destroy() to clean up resources.

Functional Parameters

The functional parameters for the function to search for attributes are as follows…

Search Response Messages

The output message for a search will contain the information on any entities found that match the search criteria. This could be any number of entities, or zero entities if none are found.

Example output:

{
"SEARCH_RESPONSE": {
"RESOLVED_ENTITY": [{
"LENS_ID": 1,
"RES_ENT_ID": 1,
"MATCH_LEVEL": 2,
"MATCH_KEY": "+DRLIC+PASSPORT-SSN",
"MATCH_SCORE": "6",
"ERRULE_CODE": "SF1",
"REF_SCORE": 6,
"MATCH_SCORES": {
"DRLIC": [{
"INBOUND_FEAT": "DL11111",
"CANDIDATE_FEAT": "DL11111",
"FULL_SCORE": 100
}],
"GROUPER_KEY": [{
"INBOUND_FEAT": "1 2 3 RS-27 ES-35 4D4A29C22CEF36DAD7B8DE1DE9724934EC7AB3CB",
"CANDIDATE_FEAT": "1 2 1 RS-27 ES-35 6BAA8B13001E779888AA3F00C8E3513E86A81F96",
"FULL_SCORE": 0
}],
"NAME": [{
"INBOUND_FEAT": "JOHN M SMITH",
"CANDIDATE_FEAT": "ROBERT M JONES",
"GNR_FN": 72,
"GNR_SN": 0,
"GNR_GN": 67,
"GENERATION_MATCH": -1,
"GNR_ON": -1
}],
"PASSPORT": [{
"INBOUND_FEAT": "PP11111 US",
"CANDIDATE_FEAT": "PP11111 US",
"FULL_SCORE": 100
}],
"SSN": [{
"INBOUND_FEAT": "111-11-1111",
"CANDIDATE_FEAT": "222-22-2222",
"FULL_SCORE": 0
}]
},
"RECORD": [{
"DATA_SOURCE": "TEST",
"ENTITY_TYPE": "PERSON",
"ENTITY_KEY": "24912928B2A701FC8E1380AC47DCC9195FC111C5",
"ENTITY_NAME": "Robert M Jones",
"RECORD_ID": "",
"MATCH_KEY": "",
"MATCH_SCORE": "",
"ERRULE_CODE": "",
"REF_SCORE": 0,
"MATCH_LEVEL": 0
}]
},
{
"LENS_ID": 1,
"RES_ENT_ID": 2,
"MATCH_LEVEL": 2,
"MATCH_KEY": "+DRLIC+PASSPORT-SSN",
"MATCH_SCORE": "6",
"ERRULE_CODE": "SF1",
"REF_SCORE": 6,
"MATCH_SCORES": {
"DRLIC": [{
"INBOUND_FEAT": "DL11111",
"CANDIDATE_FEAT": "DL11111",
"FULL_SCORE": 100
}],
"GROUPER_KEY": [{
"INBOUND_FEAT": "1 2 3 RS-27 ES-35 4D4A29C22CEF36DAD7B8DE1DE9724934EC7AB3CB",
"CANDIDATE_FEAT": "1 2 1 RS-27 ES-35 A4964CBA7975CF071C3057F9D0A4B001E3B89C34",
"FULL_SCORE": 0
}],
"NAME": [{
"INBOUND_FEAT": "JOHN M SMITH",
"CANDIDATE_FEAT": "ROBERT M JONES",
"GNR_FN": 72,
"GNR_SN": 0,
"GNR_GN": 67,
"GENERATION_MATCH": -1,
"GNR_ON": -1
}],
"PASSPORT": [{
"INBOUND_FEAT": "PP11111 US",
"CANDIDATE_FEAT": "PP11111 US",
"FULL_SCORE": 100
}],
"SSN": [{
"INBOUND_FEAT": "111-11-1111",
"CANDIDATE_FEAT": "333-33-3333",
"FULL_SCORE": 0
}]
},
"RECORD": [{
"DATA_SOURCE": "TEST",
"ENTITY_TYPE": "PERSON",
"ENTITY_KEY": "0AC50DA32F4F1DF374B6DD81BACC19F239CD1208",
"ENTITY_NAME": "Robert M Jones",
"RECORD_ID": "",
"MATCH_KEY": "",
"MATCH_SCORE": "",
"ERRULE_CODE": "",
"REF_SCORE": 0,
"MATCH_LEVEL": 0
}]
}]
}
}

Getting Resolved Entities with the Senzing Engine Interface

Overview

This article demonstrates the basic code:

from G2Engine import G2Engine

#----------------------------------------
if __name__ == '__main__':
    moduleName = "pyG2"
    iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}"
    verboseLogging = False

    # Create the G2Engine object with the G2Module.ini once per process
    engine = G2Engine()

    # Initialize the G2Engine once per process. This will take a few seconds.
    initRet = engine.initV2(moduleName, iniParams, verboseLogging)

    dataSourceCode = "TEST"
    recordID = "RECORD3"
    jsonData =  "{\"NAME_TYPE\": \"PRIMARY\", \"NAME_FIRST\": \"JANE\", \"NAME_LAST\": \"SMITH\", \"ADDR_TYPE\": \"HOME\", \"ADDR_LINE1\": \"653 STATE ROUTE 7\", \"ADDR_CITY\": \"FRESNO\", \"ADDR_STATE\": \"CA\", \"ADDR_POSTAL_CODE\": \"55073-1234\"}"
    loadID = None

    #addRecord
    ret = engine.addRecord(dataSourceCode, recordID, jsonData, loadID)

    entityID = 1
    response = bytearray("")

    #getEntityByEntityID
    ret2 = engine.getEntityByEntityIDV2(entityID, engine.G2_ENTITY_DEFAULT_FLAGS, response)
    print "GET Entity: "+str(response)

    #getEntityByRecordID
    response = bytearray("")
    ret3 = engine.getEntityByRecordIDV2(dataSourceCode, recordID, engine.G2_ENTITY_DEFAULT_FLAGS, response)
    print "GET Entity: "+str(response)
    print ""

    #getRecord
    response = bytearray("")
    ret4 = engine.getRecordV2(dataSourceCode,recordID,engine.G2_ENTITY_DEFAULT_FLAGS,response)
    print str(response)
    print ""

    #When done with all G2 requests, shut down the G2 Engine
    engine.destroy();

import com.senzing.g2.engine.G2Engine;
import com.senzing.g2.engine.G2JNI;

//...

    String moduleName = "G2JNI";
    String iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}";
    boolean verboseLogging = false;

/** init */
    G2Engine engine = new G2JNI();
    int initResult = engine.initV2(moduleName, iniParams, verboseLogging);

    String dataSourceCode = "TEST";
    String recordID = "RECORD3";
    String jsonData =  "{\"NAME_TYPE\": \"PRIMARY\", \"NAME_FIRST\": \"JANE\", \"NAME_LAST\": \"SMITH\", \"ADDR_TYPE\": \"HOME\", \"ADDR_LINE1\": \"653 STATE ROUTE 7\", \"ADDR_CITY\": \"FRESNO\", \"ADDR_STATE\": \"CA\", \"ADDR_POSTAL_CODE\": \"55073-1234\"}";
    String loadID = null;

/** addRecord */
    int ret = engine.addRecord(dataSourceCode, recordID, jsonData, loadID);

    long entityID = 1;
    StringBuffer response = new StringBuffer();

/** getEntityByEntityID */
    int ret2 = engine.getEntityByEntityIDV2(entityID, G2Engine.G2_ENTITY_DEFAULT_FLAGS, response);
    System.out.println("GET Entity: " + response.toString());

/** getEntityByRecordID */
    response = new StringBuffer();
    ret = g2.getEntityByRecordIDV2(dataSourceCode,recordID, G2Engine.G2_ENTITY_DEFAULT_FLAGS,response);
    System.out.println("GET Entity: " + response.toString());
    System.out.println("");

/** getRecord */
    response = new StringBuffer();
    ret = g2.getRecordV2(dataSourceCode, recordID, G2Engine.G2_ENTITY_DEFAULT_FLAGS, response);
    System.out.println("GET RECORD: " + response.toString());
    System.out.println("");

/** When done with all G2 requests, shut down the G2 Engine */
    int destroyResult = engine.destroy();
#include "libg2.h"
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argsz[])
{
    char *moduleName = "g2module";
    char *iniParams = "{\"PIPELINE\": {\"SUPPORTPATH\": \"/opt/senzing/g2/data\"},\"SQL\": {\"CONNECTION\": \"sqlite3://na:na@/opt/senzing/g2/sqldb/G2C.db\",\"G2CONFIGFILE\": \"/opt/senzing/g2/python/g2config.json\"}}";
    bool verboseLogging = false;

    //init
    int ret = G2_init_V2(moduleName, iniParams, verboseLogging);

    const char *dataSourceCode = "TEST";
    const char *recordID = "RECORD3";
    const char *jsonData =  "{\"NAME_TYPE\": \"PRIMARY\", \"NAME_FIRST\": \"JANE\", \"NAME_LAST\": \"SMITH\", \"ADDR_TYPE\": \"HOME\", \"ADDR_LINE1\": \"653 STATE ROUTE 7\", \"ADDR_CITY\": \"FRESNO\", \"ADDR_STATE\": \"CA\", \"ADDR_POSTAL_CODE\": \"55073-1234\"}";
    const char *loadID = NULL;

    //addRecord
    int addRet = G2_addRecord(dataSourceCode, recordID, jsonData, loadID);

    char *response = NULL;
    size_t bufSize = 0;
    const long long entityID = 4001;

    //Get entity by entityID
    int ret1 = G2_getEntityByEntityID_V2(entityID, G2_ENTITY_DEFAULT_FLAGS, &response, &bufSize, realloc);
    printf("ENTITY: %s\n", response);
    free(response);

    response = NULL;

    //Get entity by recordID
    int ret2 = G2_getEntityByRecordID_V2(dataSourceCode,recordID,G2_ENTITY_DEFAULT_FLAGS,&response, &bufSize,realloc);
    printf("ENTITY: %s\n", response);
    free(response);

    response = NULL;

    //Get record
    int ret3 = G2_getRecord_V2(dataSourceCode, recordID, G2_ENTITY_DEFAULT_FLAGS, &response, &bufSize, realloc);
    printf("RECORD: %s\n", response);
    free(response);

    //When done with all G2 requests, shut down the G2 Engine
    int destroyResult = G2_destroy();
}

Loading data and exporting is the core use case for batch style Entity Resolution. For an interactive use, we also provide methods for retrieving single resolved entities for evaluation. Resolved entities can be retrieved based on entity keys or other identifying information.

There are a few functions that are used to retrieve entity information, each based on different search criteria. With a few function calls, you can retrieve the entity data in the system quickly and easily. These function calls return the resolved entity data as a set of JSON documents.

Retrieving Entity Information with the Senzing Engine

The three core steps for utilizing the G2 Engine to retrieve entity information are:

  1. Create and initialize a new G2Engine object with an arbitrary name and the G2Module.ini that the G2Project.ini points to. There should be one G2Engine object per process.
  2. After the G2Engine object is initialized, call the functions to get the entity data. These can be called as many times as desired and from multiple threads at the same time.
  3. Once all function calls are complete, call destroy() to clean up resources.

Functional Parameters

The functional parameters for the functions to retrieve entity records are as follows…

Response

If a matching entity is found, the information for that entity will be returned as a JSON document, similar to the format returned by the batch JSON exporter.

An example document is as follows.

{
    "RESOLVED_ENTITY": {
        "RESOLVED_ID": 1,
        "LENS_ID": 1,
        "RECORD": [{
            "NAMES": [{
                "NAME_TYPE": "PRIMARY",
                "NAME_LAST": "Smith",
                "NAME_FIRST": "John",
                "NAME_MIDDLE": "M"
            }],
            "PASSPORT_NUMBER": "PP11111",
            "PASSPORT_COUNTRY": "US",
            "DRIVERS_LICENSE_NUMBER": "DL11111",
            "SSN_NUMBER": "111-11-1111",
            "DATA_SOURCE": "TEST",
            "ENTITY_TYPE": "PERSON",
            "DSRC_ACTION": "A",
            "SOURCE_ID": "observation_source_id",
            "RECORD_ID": "entity_record_id",
            "LENS": "DEFAULT",
            "ENTITY_KEY": "D8250B485CFEC5F5218F60C831CF3160E1DECAE7",
            "ENTITY_NAME": "John M Smith",
            "MATCH_KEY": "",
            "MATCH_SCORE": "",
            "ERRULE_CODE": "",
            "REF_SCORE": 0,
            "MATCH_LEVEL": 0
        }]
    },
    "RELATED_ENTITY": []
}