Senzing v3 G2Engine Finding Networks

Senzing v4 is released! Unless you are working with an existing Senzing v3 deployment, check out the v4 Python SDK!

Finding networks

findNetworkByEntityID

findNetworkByRecordID() finds all entities surrounding a requested set of entities. This includes the requested entities, paths between them, and relations to other nearby entities. Returns a JSON document that identifies the path between the each set of search entities (if the path exists), and the information for the entities in the path.

g2_engine.findNetworkByEntityID(entity_list_as_json, max_degree, buildout_degree, max_entities, response_bytearray,g2_engine_flags)
Parameters
  • entity_list_as_json: (str) A list of entities, specified by ENTITY_ID (JSON document)
  • max_degree: (int) The maximum number of degrees in paths between search entities.
  • buildout_degree: (int) The number of degrees of relationships to show around each search entity.
  • max_entities: (int) The maximum number of entities to return in the discovered network.
  • response_bytearray: (bytearray) Object to store the output of the method.
  • g2_engine_flags: (int [optional]) One or more flags used to determine response document content. Applicable flags are listed here findNetwork* flags )
Click to expand `findNetworkByEntityID()` example Click to collapse
Example
#! /usr/bin/env python3

from senzing import G2Engine, G2Exception
import json

# REPLACE /home/user/your_project with the path to your Senzing project
senzing_engine_configuration_json = '{ "PIPELINE": { "CONFIGPATH": "/home/user/your_project/etc", "SUPPORTPATH": "/home/user/your_project/data", "RESOURCEPATH": "/home/user/your_project/resources" }, "SQL": { "CONNECTION": "sqlite3://na:na@/home/user/your_project/var/sqlite/G2C.db" } }'

g2_engine = G2Engine()

entity_list = {
    "ENTITIES": [{
        "ENTITY_ID": 1
    }, {
        "ENTITY_ID": 100002
    }
    ]}

entity_list_as_json = json.dumps(entity_list)

max_degree = 2

buildout_degree = 1

max_entities = 12

response_bytearray = bytearray()

try:
    g2_engine.init("G2Engine", senzing_engine_configuration_json)

    g2_engine.findNetworkByEntityID(
        entity_list_as_json,
        max_degree,
        buildout_degree,
        max_entities,
        response_bytearray)

    g2_engine.destroy()

    print(response_bytearray.decode())

except G2Exception as err:
    print(err)
Output
{
  "ENTITY_PATHS": [
    {
      "START_ENTITY_ID": 1,
      "END_ENTITY_ID": 100002,
      "ENTITIES": [1, 100002]
    }
  ],
  "ENTITIES": [
    {
      "RESOLVED_ENTITY": {
        "ENTITY_ID": 1,
        "ENTITY_NAME": "Robert Smith",
        "RECORD_SUMMARY": [
          {
            "DATA_SOURCE": "CUSTOMERS",
            "RECORD_COUNT": 4,
            "FIRST_SEEN_DT": "2022-12-16 23:01:29.560",
            "LAST_SEEN_DT": "2022-12-16 23:01:29.584"
          }
        ],
        "LAST_SEEN_DT": "2022-12-16 23:01:29.584"
      },
      "RELATED_ENTITIES": [
        {
          "ENTITY_ID": 5,
          "MATCH_LEVEL": 2,
          "MATCH_LEVEL_CODE": "POSSIBLY_SAME",
          "MATCH_KEY": "+NAME+ADDRESS-DOB",
          "ERRULE_CODE": "CNAME_CFF_DEXCL",
          "IS_DISCLOSED": 0,
          "IS_AMBIGUOUS": 0
        },
        {
          "ENTITY_ID": 100002,
          "MATCH_LEVEL": 3,
          "MATCH_LEVEL_CODE": "POSSIBLY_RELATED",
          "MATCH_KEY": "+ADDRESS+SURNAME",
          "ERRULE_CODE": "CFF_SURNAME",
          "IS_DISCLOSED": 0,
          "IS_AMBIGUOUS": 0
        }
      ]
    },
    {
      "RESOLVED_ENTITY": {
        "ENTITY_ID": 5,
        "ENTITY_NAME": "Robert E Smith Sr",
        "RECORD_SUMMARY": [
          {
            "DATA_SOURCE": "CUSTOMERS",
            "RECORD_COUNT": 1,
            "FIRST_SEEN_DT": "2022-12-16 23:01:29.591",
            "LAST_SEEN_DT": "2022-12-16 23:01:29.591"
          },
          {
            "DATA_SOURCE": "WATCHLIST",
            "RECORD_COUNT": 1,
            "FIRST_SEEN_DT": "2022-12-16 23:01:37.096",
            "LAST_SEEN_DT": "2022-12-16 23:01:37.096"
          }
        ],
        "LAST_SEEN_DT": "2022-12-16 23:01:37.096"
      },
      "RELATED_ENTITIES": [
        {
          "ENTITY_ID": 1,
          "MATCH_LEVEL": 2,
          "MATCH_LEVEL_CODE": "POSSIBLY_SAME",
          "MATCH_KEY": "+NAME+ADDRESS-DOB",
          "ERRULE_CODE": "CNAME_CFF_DEXCL",
          "IS_DISCLOSED": 0,
          "IS_AMBIGUOUS": 0
        }
      ]
    },
    {
      "RESOLVED_ENTITY": {
        "ENTITY_ID": 100002,
        "ENTITY_NAME": "Patricia Smith",
        "RECORD_SUMMARY": [
          {
            "DATA_SOURCE": "WATCHLIST",
            "RECORD_COUNT": 1,
            "FIRST_SEEN_DT": "2022-12-16 23:01:37.149",
            "LAST_SEEN_DT": "2022-12-16 23:01:37.149"
          }
        ],
        "LAST_SEEN_DT": "2022-12-16 23:01:37.149"
      },
      "RELATED_ENTITIES": [
        {
          "ENTITY_ID": 1,
          "MATCH_LEVEL": 3,
          "MATCH_LEVEL_CODE": "POSSIBLY_RELATED",
          "MATCH_KEY": "+ADDRESS+SURNAME",
          "ERRULE_CODE": "CFF_SURNAME",
          "IS_DISCLOSED": 0,
          "IS_AMBIGUOUS": 0
        }
      ]
    }
  ]
}

findNetworkByRecordID

findNetworkByRecordID() finds all entities surrounding a requested set of entities by their RECORD_ID values. This includes the requested entities, paths between them, and relations to other nearby entities. Returns a JSON document that identifies the path between the each set of search entities (if the path exists), and the information for the entities in the path.

g2_engine.findNetworkByRecordID(record_list_as_json, max_degree, buildout_degree, max_entities, response_bytearray, g2_engine_flags)
Parameters
  • record_list_as_json: (str) A list of entities, specified by DATA_SOURCE and RECORD_ID (JSON document).
  • max_degree: (int) The maximum number of degrees in paths between search entities.
  • buildout_degree: (int) The number of degrees of relationships to show around each search entity.
  • max_entities: (int) The maximum number of entities to return in the discovered network.
  • response_bytearray: (bytearray) Object to store the output of the method.
  • g2_engine_flags: (int [optional]) One or more flags used to determine response document content. Applicable flags are listed here findNetwork* flags )
Click to expand `findNetworkByRecordID()` example Click to collapse
Example
#! /usr/bin/env python3

from senzing import G2Engine, G2Exception
import json

# REPLACE /home/user/your_project with the path to your Senzing project
senzing_engine_configuration_json = '{ "PIPELINE": { "CONFIGPATH": "/home/user/your_project/etc", "SUPPORTPATH": "/home/user/your_project/data", "RESOURCEPATH": "/home/user/your_project/resources" }, "SQL": { "CONNECTION": "sqlite3://na:na@/home/user/your_project/var/sqlite/G2C.db" } }'

g2_engine = G2Engine()

record_list = {
    "RECORDS": [{
        "DATA_SOURCE": "CUSTOMERS",
        "RECORD_ID": "1001"
    }, {
        "DATA_SOURCE": "WATCHLIST",
        "RECORD_ID": "1007"
    }
    ]}
record_list_as_json = json.dumps(record_list)

max_degree = 2

buildout_degree = 1

max_entities = 12

response_bytearray = bytearray()

try:
    g2_engine.init("G2Engine", senzing_engine_configuration_json)

    g2_engine.findNetworkByRecordID(
        record_list_as_json,
        max_degree,
        buildout_degree,
        max_entities,
        response_bytearray)

    g2_engine.destroy()

    print(response_bytearray.decode())

except G2Exception as err:
    print(err)
Output
{
  "ENTITY_PATHS": [
    {
      "START_ENTITY_ID": 1,
      "END_ENTITY_ID": 100002,
      "ENTITIES": [1, 100002]
    }
  ],
  "ENTITIES": [
    {
      "RESOLVED_ENTITY": {
        "ENTITY_ID": 1,
        "ENTITY_NAME": "Robert Smith",
        "RECORD_SUMMARY": [
          {
            "DATA_SOURCE": "CUSTOMERS",
            "RECORD_COUNT": 4,
            "FIRST_SEEN_DT": "2022-12-16 23:01:29.560",
            "LAST_SEEN_DT": "2022-12-16 23:01:29.584"
          }
        ],
        "LAST_SEEN_DT": "2022-12-16 23:01:29.584"
      },
      "RELATED_ENTITIES": [
        {
          "ENTITY_ID": 5,
          "MATCH_LEVEL": 2,
          "MATCH_LEVEL_CODE": "POSSIBLY_SAME",
          "MATCH_KEY": "+NAME+ADDRESS-DOB",
          "ERRULE_CODE": "CNAME_CFF_DEXCL",
          "IS_DISCLOSED": 0,
          "IS_AMBIGUOUS": 0
        },
        {
          "ENTITY_ID": 100002,
          "MATCH_LEVEL": 3,
          "MATCH_LEVEL_CODE": "POSSIBLY_RELATED",
          "MATCH_KEY": "+ADDRESS+SURNAME",
          "ERRULE_CODE": "CFF_SURNAME",
          "IS_DISCLOSED": 0,
          "IS_AMBIGUOUS": 0
        }
      ]
    },
    {
      "RESOLVED_ENTITY": {
        "ENTITY_ID": 5,
        "ENTITY_NAME": "Robert E Smith Sr",
        "RECORD_SUMMARY": [
          {
            "DATA_SOURCE": "CUSTOMERS",
            "RECORD_COUNT": 1,
            "FIRST_SEEN_DT": "2022-12-16 23:01:29.591",
            "LAST_SEEN_DT": "2022-12-16 23:01:29.591"
          },
          {
            "DATA_SOURCE": "WATCHLIST",
            "RECORD_COUNT": 1,
            "FIRST_SEEN_DT": "2022-12-16 23:01:37.096",
            "LAST_SEEN_DT": "2022-12-16 23:01:37.096"
          }
        ],
        "LAST_SEEN_DT": "2022-12-16 23:01:37.096"
      },
      "RELATED_ENTITIES": [
        {
          "ENTITY_ID": 1,
          "MATCH_LEVEL": 2,
          "MATCH_LEVEL_CODE": "POSSIBLY_SAME",
          "MATCH_KEY": "+NAME+ADDRESS-DOB",
          "ERRULE_CODE": "CNAME_CFF_DEXCL",
          "IS_DISCLOSED": 0,
          "IS_AMBIGUOUS": 0
        }
      ]
    },
    {
      "RESOLVED_ENTITY": {
        "ENTITY_ID": 100002,
        "ENTITY_NAME": "Patricia Smith",
        "RECORD_SUMMARY": [
          {
            "DATA_SOURCE": "WATCHLIST",
            "RECORD_COUNT": 1,
            "FIRST_SEEN_DT": "2022-12-16 23:01:37.149",
            "LAST_SEEN_DT": "2022-12-16 23:01:37.149"
          }
        ],
        "LAST_SEEN_DT": "2022-12-16 23:01:37.149"
      },
      "RELATED_ENTITIES": [
        {
          "ENTITY_ID": 1,
          "MATCH_LEVEL": 3,
          "MATCH_LEVEL_CODE": "POSSIBLY_RELATED",
          "MATCH_KEY": "+ADDRESS+SURNAME",
          "ERRULE_CODE": "CFF_SURNAME",
          "IS_DISCLOSED": 0,
          "IS_AMBIGUOUS": 0
        }
      ]
    }
  ]
}

If you have any questions, contact Senzing Support. Support is 100% FREE!