NAV Navbar
Java G2Command shell
  • Introduction
  • Quickstart
  • G2Module
  • G2Config
  • G2Audit
  • Getting Stuff Done
  • Introduction

    Welcome to the Senzing ER 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

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

    G2Module

    Engine

    Initialization

    Example code:

    import com.senzing.g2.engine.G2Engine;
    import com.senzing.g2.engine.G2JNI;
    
    //...
    
        String moduleName = "G2JNI";
        String iniFilename = args[0];
        boolean verboseLogging = false;
    
    /** init */    
        G2Engine engine = new G2JNI();
        int initResult = engine.init(moduleName, iniFilename, verboseLogging);
    
    
    python G2Command.py
    

    To start using Senzing ER, you must first create and initialize the engine -- this should be done once per process. Create a new instance of the Senzing ER engine by assigning new G2JNI() to a variable. Then, call the init method to initialize the engine. During the call, the init method accepts three parameters:

    Calling this function will return "0" upon success - useful for error handling.

    Uninitialization

    Example code:

    /** destroy */
        int destroyResult = engine.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 unitialize Senzing ER and clean up resources. You should always do this once at the end of each process.

    Statistics

    Example code:

    /** stats */
        String stats = engine.stats();
    
        System.out.println("STATS: " + stats);
    
    

    Example response:

    {u'workload': {u'retries': 0, u'candidateBuilders': [], u'cacheHit': [], u'busyWait': 0, u'ambiguousTest': 0, u'longBusyWait': 0, u'cacheMiss': [], u'records': 0, u'unresolveTest': 0, u'genericDetect': [], u'candidates': 0, u'grouperKeyMatch': 0, u'duration': 0, u'scoredPairs': [], u'redoTriggers': [], u'delete records': 0}}
    
    

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

    Export Config

    Example code:

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

    Example response is really, really long...

    Call exportConfig to retrieve your Senzing ER 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 one parameter as input:

    License Info

    Example code:

    /** license */
        System.out.println("LICENSE: " + engine.license());
        System.out.println("");
    
    

    Example response:

    {u'customer': u'', u'licenseType': u'EVAL', u'expireDate': u'2018-03-13', u'billing': u'', u'licenseLevel': u'', u'contract': u'', u'recordLimit': 1000000, u'issueDate': u'2018-01-12'}
    
    

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

    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:

        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());
    
    

    Once the Senzing ER engine is initialized, use addRecord() to load a record into the Senzing ER 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 ER repository. In particular, addRecordWithReturnedRecordID() accepts four parameters as input:

    Deleting Records

    Example code:

        String dataSourceCode = "TEST";
        String recordID = "RECORD3";
        String loadID = null;
    
    /** deleteRecord */
        int ret = engine.deleteRecord(dataSourceCode, recordID, loadID);
    
    

    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:

    Replacing Records

    Example code:

        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);
    
    

    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() 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:

    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 ER engine provides real-time search capabilities that are easily accessed via the available G2Module.py interface.

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

    Retrieve a Record

    Example code:

        String dataSourceCode = "TEST";
        String recordID = "RECORD3";
        StringBufer response = new StringBuffer();
    
    /** getRecord */
        int ret = engine.getRecord(dataSourceCode, recordID, response);
    
        System.out.println("GET RECORD: " + response.toString());
        System.out.println("");
    
    

    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\",\"LOAD_ID\":\"\",\"LENS\":\"DEFAULT\",\"RECORD_ID\":\"entity_record_id\"}",
      "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": [
        "LENS: DEFAULT"
      ],
      "DATA_SOURCE": "TEST",
      "RECORD_ID": "entity_record_id",
      "ENTITY_TYPE": "TEST",
      "ENTITY_KEY": "D8250B485CFEC5F5218F60C831CF3160E1DECAE7",
      "OBS_ENT_HASH": "D8250B485CFEC5F5218F60C831CF3160E1DECAE7"
    }
    
    

    Use getRecord() 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 ER engine is initialized, getRecord() can be called as many times as desired and from multiple threads at the same time. The getRecord() function accepts three parameters as input:

    Example code:

        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.getEntityByEntityID(entityID, response);
        System.out.println("GET Entity: " + response.toString());
    
    //...
    
        response = new StringBuffer();
    
    /** getEntityByRecordID */
        int ret3 = engine.getEntityByRecordID(dataSourceCode,recordID,response);
        System.out.println("GET Entity: " + response.toString());
    
    //... 
    
        response = new StringBuffer();
    
    /** searchByAttributes */
        int ret4 = engine.searchByAttributes(jsonData, response);
        System.out.println("GET Entity: " + response.toString());
    
    

    Example return:

    {
      "RESOLVED_ENTITY": {
        "ENTITY_ID": 3001,
        "LENS_ID": 1,
        "FEATURES": {
          "DRLIC": [
            {
              "FEAT_DESC": "DL11111",
              "LIB_FEAT_ID": 3003,
              "FEAT_DESC_VALUES": [
                {
                  "FEAT_DESC": "DL11111",
                  "LIB_FEAT_ID": 3003
                }
              ]
            }
          ],
          "NAME": [
            {
              "FEAT_DESC": "JOHN M SMITH",
              "LIB_FEAT_ID": 3001,
              "UTYPE_CODE": "PRIMARY",
              "FEAT_DESC_VALUES": [
                {
                  "FEAT_DESC": "JOHN M SMITH",
                  "LIB_FEAT_ID": 3001
                }
              ]
            }
          ],
          "PASSPORT": [
            {
              "FEAT_DESC": "PP11111 US",
              "LIB_FEAT_ID": 10,
              "FEAT_DESC_VALUES": [
                {
                  "FEAT_DESC": "PP11111 US",
                  "LIB_FEAT_ID": 10
                }
              ]
            }
          ],
          "SSN": [
            {
              "FEAT_DESC": "111-11-1111",
              "LIB_FEAT_ID": 3002,
              "FEAT_DESC_VALUES": [
                {
                  "FEAT_DESC": "111-11-1111",
                  "LIB_FEAT_ID": 3002
                }
              ]
            }
          ]
        },
        "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",
              "LOAD_ID": "",
              "LENS": "DEFAULT",
              "RECORD_ID": "entity_record_id",
              "ENTITY_KEY": "D8250B485CFEC5F5218F60C831CF3160E1DECAE7",
              "ENTITY_NAME": "John M Smith",
              "MATCH_KEY": "",
              "MATCH_SCORE": "",
              "ERRULE_CODE": "",
              "REF_SCORE": 0,
              "MATCH_LEVEL": 0
            },
            "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": [
              "LENS: DEFAULT"
            ]
          }
        ]
      },
      "RELATED_ENTITIES": [
        {
          "ENTITY_ID": 1,
          "LENS_ID": 1,
          "MATCH_LEVEL": 3,
          "MATCH_KEY": "+SSN+DRLIC+PASSPORT",
          "MATCH_SCORE": "10",
          "ERRULE_CODE": "SF1E",
          "REF_SCORE": 6,
          "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": 25
                  }
                ]
              },
              {
                "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": 24
                  }
                ]
              }
            ],
            "DRLIC": [
              {
                "FEAT_DESC": "DL11111 NV",
                "LIB_FEAT_ID": 9,
                "FEAT_DESC_VALUES": [
                  {
                    "FEAT_DESC": "DL11111 NV",
                    "LIB_FEAT_ID": 9
                  }
                ]
              }
            ],
            "EMAIL_ADDR": [
              {
                "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": 23
                  }
                ]
              }
            ],
            "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
                  }
                ]
              }
            ]
          },
          "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",
                "ENTITY_KEY": "DF3B1BE391A2BBDBA920EC75D0A8009A1CEEA347",
                "ENTITY_NAME": "Mr Robert M Jones Jr",
                "MATCH_KEY": "",
                "MATCH_SCORE": "",
                "ERRULE_CODE": "",
                "REF_SCORE": 0,
                "MATCH_LEVEL": 0
              },
              "NAME_DATA": [
                "PRIMARY: Jones Robert M Mr Jr"
              ],
              "ATTRIBUTE_DATA": [
                "DOB: 1/2/1981",
                "GENDER: M"
              ],
              "IDENTIFIER_DATA": [
                "DRLIC: DL11111 NV",
                "EMAIL_ADDR: 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": "",
                "ENTITY_KEY": "FF1C69034FA4B3D82193A42843937478EBA2CB61",
                "ENTITY_NAME": "Bobby Jones",
                "MATCH_KEY": "+NAME+DOB+GENDER+ADDRESS",
                "MATCH_SCORE": "14",
                "ERRULE_CODE": "CNAME_CFF_CEXCL",
                "REF_SCORE": 8,
                "MATCH_LEVEL": 1
              },
              "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": []
            }
          ]
        },
        {
          "ENTITY_ID": 3,
          "LENS_ID": 1,
          "MATCH_LEVEL": 3,
          "MATCH_KEY": "+PASSPORT",
          "MATCH_SCORE": "3",
          "ERRULE_CODE": "SF1E",
          "REF_SCORE": 6,
          "FEATURES": {
            "ADDRESS": [
              {
                "FEAT_DESC": "333 3RD ST LAS VEGAS NV 89333",
                "LIB_FEAT_ID": 32,
                "UTYPE_CODE": "HOME",
                "FEAT_DESC_VALUES": [
                  {
                    "FEAT_DESC": "333 3RD ST LAS VEGAS NV 89333",
                    "LIB_FEAT_ID": 32
                  }
                ]
              }
            ],
            "NAME": [
              {
                "FEAT_DESC": "MARTIN JONZE",
                "LIB_FEAT_ID": 31,
                "UTYPE_CODE": "PRIMARY",
                "FEAT_DESC_VALUES": [
                  {
                    "FEAT_DESC": "MARTIN JONZE",
                    "LIB_FEAT_ID": 31
                  }
                ]
              }
            ],
            "NATIONAL_ID": [
              {
                "FEAT_DESC": "11111111",
                "LIB_FEAT_ID": 33,
                "FEAT_DESC_VALUES": [
                  {
                    "FEAT_DESC": "11111111",
                    "LIB_FEAT_ID": 33
                  }
                ]
              }
            ],
            "PASSPORT": [
              {
                "FEAT_DESC": "PP11111 US",
                "LIB_FEAT_ID": 10,
                "FEAT_DESC_VALUES": [
                  {
                    "FEAT_DESC": "PP11111 US",
                    "LIB_FEAT_ID": 10
                  }
                ]
              }
            ]
          },
          "RECORDS": [
            {
              "JSON_DATA": {
                "CELL_PHONE_NUMBER": "",
                "DATA_SOURCE": "PEOPLE",
                "DATE_OF_BIRTH": "",
                "DRIVERS_LICENSE_NUMBER": "",
                "DRIVERS_LICENSE_STATE": "",
                "DSRC_ACTION": "A",
                "EMAIL_ADDRESS": "",
                "ENTITY_TYPE": "PEOPLE",
                "GENDER": "",
                "HOME_ADDR_CITY": "Las Vegas",
                "HOME_ADDR_COUNTRY": "",
                "HOME_ADDR_LINE1": "333 3rd St",
                "HOME_ADDR_LINE2": "",
                "HOME_ADDR_LINE3": "",
                "HOME_ADDR_POSTAL_CODE": "89333",
                "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": "CA",
                "NIN_NUMBER": "11111111",
                "PASSPORT_COUNTRY": "US",
                "PASSPORT_NUMBER": "PP11111",
                "PRIMARY_NAME_FIRST": "Martin",
                "PRIMARY_NAME_LAST": "Jonze",
                "PRIMARY_NAME_MIDDLE": "",
                "PRIMARY_NAME_PREFIX": "",
                "PRIMARY_NAME_SUFFIX": "",
                "RECORD_ID": "1003",
                "SOCIAL_HANDLE": "",
                "SOCIAL_NETWORK": "",
                "SSN_NUMBER": "",
                "WORK_PHONE_NUMBER": "",
                "ENTITY_KEY": "2BEEAB3DFA2BBA2935B55BB6BF3A129A98AF4250",
                "ENTITY_NAME": "Martin Jonze",
                "MATCH_KEY": "",
                "MATCH_SCORE": "",
                "ERRULE_CODE": "",
                "REF_SCORE": 0,
                "MATCH_LEVEL": 0
              },
              "NAME_DATA": [
                "PRIMARY: Jonze Martin"
              ],
              "ATTRIBUTE_DATA": [],
              "IDENTIFIER_DATA": [
                "NATIONAL_ID: 11111111 CA",
                "PASSPORT: PP11111 US"
              ],
              "ADDRESS_DATA": [
                "HOME: 333 3rd St Las Vegas NV 89333"
              ],
              "PHONE_DATA": [],
              "RELATIONSHIP_DATA": [],
              "ENTITY_DATA": [],
              "OTHER_DATA": []
            }
          ]
        }
      ]
    }
    
    

    Entity searching is a key component for interactive use of Entity Resolution intelligence. The core Senzing ER engine provides real-time search capabilities that are easily accessed via the Senzing ER API. Senzing ER offers three primary 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 getEntityByEntityID() to retrieve entity data based on the ID of a resolved identity. This function accepts two parameters as input:

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

    Finally, use searchByAttributes() to retrieve entity data based on a user-specified set of entity attributes. This function accepts two parameters as input:

    Process

    The process() and processWithResponse() 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.

    Reporting

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

    Export JSON Entity Report

    Example code:

        /** define a flag */
        int flag = 0x1;
    
        /** exportJSONEntityReport */
        long exportHandle = engine.exportJSONEntityReport(flag);
    
        /** fetchNext */
        String response = engine.fetchNext(exportHandle);
        System.out.println(response);
    
        /** closeExport */
        engine.closeExport(exportHandle);
    
    

    Example output:

    {"RESOLVED_ENTITY":{"ENTITY_ID":1,"LENS_ID":1,"RECORDS":[{"JSON_DATA":{"NAME_TYPE":"PRIMARY","NAME_FIRST":"JOE","NAME_MIDDLE":"H","NAME_LAST":"SMITH","ADDR_TYPE":"HOME","ADDR_LINE1":"653 STATE ROUTE 7","ADDR_CITY":"FRESNO","ADDR_STATE":"CA","ADDR_POSTAL_CODE":"55073","DATE_OF_BIRTH":"1965-05-23","SSN_NUMBER":"345678999","DATA_SOURCE":"TEST","ENTITY_TYPE":"TEST","DSRC_ACTION":"A","LOAD_ID":"","LENS":"DEFAULT","RECORD_ID":"RECORD1","ENTITY_KEY":"E37AAD09DA421DEF77DAD493BA0430AA307BA997","ENTITY_NAME":"JOE H SMITH","MATCH_KEY":"","MATCH_SCORE":"","ERRULE_CODE":"","REF_SCORE":0,"MATCH_LEVEL":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"]},{"JSON_DATA":{"NAME_TYPE":"PRIMARY","NAME_FIRST":"JOSEPH","NAME_LAST":"SMITH","ADDR_TYPE":"HOME","ADDR_LINE1":"653 STATE ROUTE 7","ADDR_CITY":"FRESNO","ADDR_STATE":"CA","ADDR_POSTAL_CODE":"55073-1234","DATE_OF_BIRTH":"1965-05-23","SSN_NUMBER":"345678999","DATA_SOURCE":"TEST","ENTITY_TYPE":"TEST","DSRC_ACTION":"A","LOAD_ID":"","LENS":"DEFAULT","RECORD_ID":"RECORD2","ENTITY_KEY":"D66C1742ADA5BB5A4545834AF223DD075B7E4E9E","ENTITY_NAME":"JOSEPH SMITH","MATCH_KEY":"+NAME+DOB+ADDRESS+SSN","MATCH_SCORE":"17","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","REF_SCORE":10,"MATCH_LEVEL":1},"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"]}]}}
    
    

    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 resolved entity. Note that successive calls of fetchNext() will export successive rows of entity data. The fetchNext() method accepts one parameter 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 a flag */
        int flag = 0x1;
    
        /** exportCSVEntityReport */
        long exportHandle = engine.exportCSVEntityReport(flag);
    
        /** fetchNext */
        String response = engine.fetchNext(exportHandle);
        System.out.println(response);
    
        /** closeExport */
        engine.closeExport(exportHandle);
    
    

    Example response:

    1,"JOE H SMITH",0,0,"","TEST","RECORD1","{""NAME_TYPE"":""PRIMARY"",""NAME_FIRST"":""JOE"",""NAME_MIDDLE"":""H"",""NAME_LAST"":""SMITH"",""ADDR_TYPE"":""HOME"",""ADDR_LINE1"":""653 STATE ROUTE 7"",""ADDR_CITY"":""FRESNO"",""ADDR_STATE"":""CA"",""ADDR_POSTAL_CODE"":""55073"",""DATE_OF_BIRTH"":""1965-05-23"",""SSN_NUMBER"":""345678999"",""DATA_SOURCE"":""TEST"",""ENTITY_TYPE"":""TEST"",""DSRC_ACTION"":""A"",""LOAD_ID"":"""",""LENS"":""DEFAULT"",""RECORD_ID"":""RECORD1""}"
    
    

    There are three steps to exporting resolved entity data from the G2Engine object in CSV format. First, use the exportCSVEntityReport() method to generate a long integer, referred to here as an 'exportHandle'. The exportCSVEntityReport() method accepts one 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 resolved entity. Note that the first call of fetchNext() may yield a header row, and that successive calls of fetchNext() will export successive rows of entity data. The fetchNext() method accepts one parameter 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:

    Entity Export Flags

    The Senzing ER engine allows you to specify which kinds of entity matches to export. In particular, you can choose from five different integer 'flags' to input into exportJSONEntityReport() or exportCSVEntityReport(). Each flag indicates a different category of entity match details to include in your export:

    Flag Meaning
    0x1 Include all entity data in the export (recommended)
    0x4 Only include match-level-1 (same entity) matches
    0x8 Only include match-level 2 (possibly same entity) matches
    0x16 Only include match-level 3 (possibly related entity) matches
    0x32 Only include match-level 4 (disclosed relationship) matches

    Data Repository

    Purge

    Example code:

    /** purgeRepository */
        int ret = engine.purgeRepository();
    
        System.out.println("PURGED Repository");
    
    

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

    G2Config

    (Intro paragraph here)

    Initialization

    Example code:

    import com.senzing.g2.engine.G2Engine;
    import com.senzing.g2.engine.G2JNI;
    import com.senzing.g2.engine.G2Config;
    import com.senzing.g2.engine.G2ConfigJNI;
    
    //...
    
        String G2_MODULE_NAME = "EngineSample";
        String iniFilename = "/opt/senzing/g2/python/G2Module.ini";
        boolean USE_VERBOSE_LOGGING = false;
    
    //...
    
        G2Config engine = new G2ConfigJNI();
        int ret = engine.init(G2_MODULE_NAME, iniFilename, USE_VERBOSE_LOGGING);
    
    

    To initialize the G2Config object, use the init() method -- this must be called prior to any other calls. The init() method returns 0 upon success, and it accepts three parameters:

    Uninitialization

    Example code:

    /** destroy */
        int destroyResult = engine.destroy();
    
    

    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.

    Create

    Example code:

    /** create */
        long configHandle = engine.create();
    
    

    The create() method creates a stock Senzing ER 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 ER configuration, and can be used to represent said Senzing ER configuration in later function calls (as will be shown below).

    Load

    Example code:

    /** load */
        String jsonConfig = "";
        long configHandle =  engine.load(jsonConfig);
    
    

    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:

    //...
        long configHandle = engine.create();
        StringBuffer response = new StringBuffer();
    
    //...
    
    /** save */ 
        int ret = engine.save(configHandle, response );
    
    

    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 two parameters:

    Close

    Example code:

    //...
        long configHandle = engine.create();
    
    //...
    /** close */
        engine.close(configHandle);
    
    

    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:

    //...
        long configHandle = engine.create();
        String code = "CUSTOMER";
    
    //...
    /** add data source */
        int ret = engine.addDataSource(configHandle, code);
    
    /** add data source with ID */
        int id = 0;
        int ret2 = engine.addDataSourceWithID(configHandle, code, id);
    
    

    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 returns 0 upon success, and otherwise for error. 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:

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

    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 two parameters:

    ## Get Last Exception

    Example code:

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

    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.

    Clear Last Exception

    Example code:

    /** clear last exception */
        engine.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:

    import com.senzing.g2.engine.G2Engine;
    import com.senzing.g2.engine.G2JNI;
    
    import com.senzing.g2.engine.G2Audit;
    import com.senzing.g2.engine.G2AuditJNI;
    
    //...
    
        String moduleName = "EngineSample";
        String iniFilename = "/opt/senzing/g2/python/G2Module.ini";
        boolean verboseLogging = false;
    
    /** initialize */
    
        G2Audit engine = new G2AuditJNI();
        int ret = engine.init(moduleName, iniFilename, verboseLogging);
    
    

    To initialize the G2Audit object, use the init() method -- this must be called prior to any other calls. The init() method returns 0 upon success, and it accepts three parameters:

    Uninitialization

    Example code:

    /** destroy */
        int destroyResult = engine.destroy();
    
    

    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. Like its init() counterpart, destroy() returns 0 upon success.

    Open New Session

    Example code:

    /** create session handle */
        long sessionHandle = engine.openSession();
    
    

    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).

    Close Session

    Example code:

    //...
        long sessionHandle = engine.openSession();
    
    //...body of code here...
    
    /** closeSession */
        engine.closeSession(sessionHandle);
    
    

    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:

        long sessionHandle = engine.openSession();
    
        StringBuffer response = new StringBuffer();
        int match_level = 1;
    
    /** getSummaryData */
        int ret = engine.getSummaryData(sessionHandle, response);
        System.out.println("Summary data: " + response.toString());
    
    //...
    
    /** close session when done */
        engine.closeSession();
    
    

    Example output:

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

    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 two parameters as input:

    Used Match Keys

    Example code:

        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("Used key data: " + response.toString());
    
    //...
    
    /** close session when done */
        engine.closeSession();
    
    

    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 five parameters as input:

    Used Principles

    Example code:

        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("Used principle data: " + response.toString());
    
    //...
    
    /** close session when done */
        engine.closeSession(); 
    
    

    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 five parameters as input:

    Get Audit Report

    Example code:

    //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();
    
    

    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 an '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 one parameter 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 closeExport() method accepts one parameter as input:

    Getting Stuff Done

    Adding and Removing Records with the Senzing Engine Interface

    Overview

    This article demonstrates the basic code:

    import com.senzing.g2.engine.G2Engine;
    import com.senzing.g2.engine.G2JNI;
    
    //...
    
        String moduleName = "G2JNI";
        String iniFilename = args[0];
        boolean verboseLogging = false;
    
    /** init */    
        G2Engine engine = new G2JNI();
        int initResult = engine.init(moduleName, iniFilename, 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);
    
        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 = g2.deleteRecord(dataSourceCode,recordID, loadID);
    
    /** When done with all G2 requests, shut down the G2 Engine */
        int destroyResult = engine.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 the G2Module.ini that the G2Project.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:

    import com.senzing.g2.engine.G2Engine;
    import com.senzing.g2.engine.G2JNI;
    
    //...
    
        String moduleName = "G2JNI";
        String iniFilename = args[0];
        boolean verboseLogging = false;
    
    /** init */    
        G2Engine engine = new G2JNI();
        int initResult = engine.init(moduleName, iniFilename, 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();
    
    
    cd /opt/senzing/g2/python
    python G2Command.py
    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 G2Module.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, 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 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:

    import com.senzing.g2.engine.G2Engine;
    import com.senzing.g2.engine.G2JNI;
    
    //...
    
        String moduleName = "G2JNI";
        String iniFilename = args[0];
        boolean verboseLogging = false;
    
    /** init */    
        G2Engine engine = new G2JNI();
        int initResult = engine.init(moduleName, iniFilename, 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.getEntityByEntityID(entityID, response);
        System.out.println("GET Entity: " + response.toString());
    
    /** getEntityByRecordID */
        response = new StringBuffer();
        ret = g2.getEntityByRecordID(dataSourceCode,recordID,response);
        System.out.println("GET Entity: " + response.toString());
        System.out.println("");
    
    /** getRecord */
        response = new StringBuffer();
        ret = g2.getRecord(dataSourceCode, recordID, 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();
    
    

    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, 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 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": []
    }