G2Engine Finding Paths
Version 3.x
Version 2.x
Finding Paths
findPathByEntityID
findPathByEntityID()
finds the most efficient relationship between two entities path based on the parameters, and returns a JSON document with an ENTITY_PATHS section that details the path between the entities. The ENTITIES sections details information on the entities.
Paths are found using known relationships with other entities.
g2_engine.findPathByEntityID(start_entity_id, end_entity_id, max_degree, response_bytearray, g2_engine_flags)
Parameters
- start_entity_id: (int) The ENTITY_ID for the starting entity of the search path.
- end_entity_id: (int) The ENTITY_ID for the ending entity of the search path.
- max_degree: (int) The maximum path length to from start_entity_id to end_entity_id.
- 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 findPath* flags)
Click to expand `findPathByEntityID()` example
Example
#! /usr/bin/env python3
from senzing import G2Engine, G2Exception
# 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()
start_entity_id = 1
end_entity_id = 100002
max_degree = 3
# Find the path by entity ID.
response_bytearray = bytearray([])
try:
g2_engine.init("G2Engine", senzing_engine_configuration_json)
g2_engine.findPathByEntityID(
start_entity_id,
end_entity_id,
max_degree,
response_bytearray)
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": 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
}
]
}
]
}
findPathByRecordID
findPathByEntityID()
finds the most efficient relationship between two entities path based on the parameters by RECORD_ID values, and returns a JSON document with an ENTITY_PATHS section that details the path between the entities. The ENTITIES sections details information on the entities.
Paths are found using known relationships with other entities.
g2_engine.findPathByRecordID(start_data_source_code, start_record_id, end_data_source_code, end_record_id, max_degree, response_bytearray, g2_engine_flags)
Parameters
- start_data_source_code: (str) The data source for the starting entity of the search path.
- start_record_id: (str) The RECORD_ID for the starting entity of the search path.
- end_data_source_code: (str) The data source for the ending entity of the search path.
- end_record_id: (str) The RECORD_ID for the ending entity of the search path.
- max_degree: (int) The maximum path length to from start_entity_id to end_entity_id.
- 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 findPath* flags)
Click to expand `findPathByEntityID()` example
Example
#! /usr/bin/env python3
from senzing import G2Engine, G2Exception
# 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()
start_data_source_code = 'CUSTOMERS'
start_record_id = '1001'
end_data_source_code = 'WATCHLIST'
end_record_id = '1007'
max_degree = 3
# Find the path by entity ID.
response_bytearray = bytearray([])
try:
g2_engine.init("G2Engine", senzing_engine_configuration_json)
g2_engine.findPathByRecordID(
start_data_source_code,
start_record_id,
end_data_source_code,
end_record_id,
max_degree,
response_bytearray)
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": 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
}
]
}
]
}
findPathExcludingByEntityID
findPathExcludingByEntityID()
finds the most efficient relationship between two entities path based on the parameters while preferentially excluding specific ENTITY_IDs, and returns a JSON document with an ENTITY_PATHS section that details the path between the entities. The ENTITIES sections details information on the entities.
Paths are found using known relationships with other entities.
By default, any excluded entities are strictly excluded. The G2_FIND_PATH_PREFER_EXCLUDE
flag sets the exclusion to preferred instead of strict exclusion. Preferred exclusion means that if an excluded entity is the only one in the path, it will be used, but strict will never include excluded entities in the path.
g2_engine.findPathExcludingByEntityID(start_entity_id, end_entity_id, max_degree, excluded_entities_as_json, response_bytearray, g2)
Parameters
- start_entity_id: (int) The entity ID for the starting entity of the search path.
- end_entity_id: (int) The entity ID for the ending entity of the search path.
- max_degree: (int) The maximum path length to from start_entity_id to end_entity_id.
- excluded_entities_as_json: (str) Entities that should be avoided on the path (JSON document).
- 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 findPath* flags)
Click to expand `findPathExcludingByEntityID()` example
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()
start_entity_id = 1
end_entity_id = 100002
max_degree = 3
excluded_entities = {
"ENTITIES": [{
"ENTITY_ID": 5
}]}
excluded_entities_as_json = json.dumps(excluded_entities)
response_bytearray = bytearray()
try:
g2_engine.init("G2Engine", senzing_engine_configuration_json)
g2_engine.findPathExcludingByEntityID(
start_entity_id,
end_entity_id,
max_degree,
excluded_entities_as_json,
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": 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
}
]
}
]
}
findPathExcludingByRecordID
findPathExcludingByEntityID()
finds the most efficient relationship between two entities path based on the parameters by RECORD_IDs while preferentially excluding specific ENTITY_IDs, and returns a JSON document with an ENTITY_PATHS section that details the path between the entities. The ENTITIES sections details information on the entities.
Paths are found using known relationships with other entities.
By default, any excluded entities are strictly excluded. The G2_FIND_PATH_PREFER_EXCLUDE
flag sets the exclusion to preferred instead of strict exclusion. Preferred exclusion means that if an excluded entity is the only one in the path, it will be used, but strict will never include excluded entities in the path.
g2_engine.findPathExcludingByRecordID(start_data_source_code, start_record_id, end_data_source_code, end_record_id, max_degree, excluded_entities_as_json, response_bytearray, g2_engine_flags)
Parameters
- start_data_source_code: (str) The data source for the starting entity of the search path.
- start_record_id: (str) The RECORD_ID for the starting entity of the search path.
- end_data_source_code: (str) The data source for the ending entity of the search path.
- end_record_id: (str) The RECORD_ID for the ending entity of the search path.
- max_degree: (int) The maximum path length to from start_entity_id to end_entity_id.
- excluded_entities_as_json: (str) Entities that should be avoided on the path (JSON document)
- 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 findPath* flags)
Click to expand `findPathExcludingByEntityID()` example
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()
start_data_source_code = 'CUSTOMERS'
start_record_id = '1001'
end_data_source_code = 'WATCHLIST'
end_record_id = '1007'
max_degree = 3
excluded_entities = {
"ENTITIES": [{
"ENTITY_ID": 5
}]}
excluded_entities_as_json = json.dumps(excluded_entities)
response_bytearray = bytearray()
try:
g2_engine.init("G2Engine", senzing_engine_configuration_json)
g2_engine.findPathExcludingByRecordID(
start_data_source_code,
start_record_id,
end_data_source_code,
end_record_id,
max_degree,
excluded_entities_as_json,
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": 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
}
]
}
]
}
findPathIncludingSourceByEntityID
findPathIncludingSourceByEntityID()
finds the most efficient relationship between two entities path based on the parameters, requiring a path entity to include a RECORD_ID from specified data source. Specific ENTITY_IDs to exclude can optionally be listed.
Returns a JSON document with an ENTITY_PATHS section that details the path between the entities. The ENTITIES sections details information on the entities.
Paths are found using known relationships with other entities.
By default, any excluded entities are strictly excluded. The G2_FIND_PATH_PREFER_EXCLUDE
flag sets the exclusion to preferred instead of strict exclusion. Preferred exclusion means that if an excluded entity is the only one in the path, it will be used, but strict will never include excluded entities in the path.
g2_engine.findPathIncludingSourceByEntityID(start_entity_id, end_entity_id, max_degree, excluded_entities_as_json, required_dsrcs_as_json, response_bytearray, g2_engine_flags)
Parameters
- start_entity_id: (int) The entity ID for the starting entity of the search path
- end_entity_id: (int) The entity ID for the ending entity of the search path
- max_degree: (int) The maximum path length to from start_entity_id to end_entity_id.
- excluded_entities_as_json: (str) Entities that should be avoided on the path (JSON document).
- required_dsrcs_as_json: (str) Entities that should be avoided on the path (JSON document).
- 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 findPath* flags)
Click to expand `findPathIncludingSourceByEntityID()` example
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()
start_entity_id = 1
end_entity_id = 100002
max_degree = 3
excluded_entities = {
"ENTITIES": [{
"ENTITY_ID": 5
}]}
excluded_entities_as_json = json.dumps(excluded_entities)
required_dsrcs = {
"DATA_SOURCES": [
"WATCHLIST"
]}
required_dsrcs_as_json = json.dumps(required_dsrcs)
response_bytearray = bytearray()
try:
g2_engine.init("G2Engine", senzing_engine_configuration_json)
g2_engine.findPathIncludingSourceByEntityID(
start_entity_id,
end_entity_id,
max_degree,
excluded_entities_as_json,
required_dsrcs_as_json,
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":
[]
}
],
"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": 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
}
]
}
]
}
findPathIncludingSourceByRecordID
findPathIncludingSourceByRecordID()
finds the most efficient relationship between two entities path based on the parameters by RECORD_IDs, requiring a path entity to include a RECORD_ID from specified data source. Specific ENTITY_IDs to exclude can optionally be listed.
Returns a JSON document with an ENTITY_PATHS section that details the path between the entities. The ENTITIES sections details information on the entities.
Paths are found using known relationships with other entities.
By default, any excluded entities are strictly excluded. The G2_FIND_PATH_PREFER_EXCLUDE
flag sets the exclusion to preferred instead of strict exclusion. Preferred exclusion means that if an excluded entity is the only one in the path, it will be used, but strict will never include excluded entities in the path.
g2_engine.findPathIncludingSourceByRecordID(start_data_source_code, start_record_id, end_data_source_code, end_record_id, max_degree, excluded_entities_as_json, required_dsrcs_as_json, response_bytearray, g2_engine_flags)
Parameters
- start_data_source_code: (str) The data source for the starting entity of the search path.
- start_record_id: (str) The RECORD_ID for the starting entity of the search path.
- end_data_source_code: (str) The data source for the ending entity of the search path.
- end_record_id: (str) The RECORD_ID for the ending entity of the search path.
- max_degree: (int) The maximum path length to from start_entity_id to end_entity_id.
- excluded_entities_as_json: (str) Entities that should be avoided on the path (JSON document).
- required_dsrcs_as_json: (str) Entities that should be avoided on the path (JSON document).
- 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 findPath* flags)
Click to expand `findPathIncludingSourceByRecordID()` example
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()
start_data_source_code = 'CUSTOMERS'
start_record_id = '1001'
end_data_source_code = 'WATCHLIST'
end_record_id = '1007'
max_degree = 3
excluded_entities = {
"ENTITIES": [{
"ENTITY_ID": 5
}]}
excluded_entities_as_json = json.dumps(excluded_entities)
required_dsrcs = {
"DATA_SOURCES": [
"WATCHLIST"
]}
required_dsrcs_as_json = json.dumps(required_dsrcs)
response_bytearray = bytearray()
try:
g2_engine.init("G2Engine", senzing_engine_configuration_json)
g2_engine.findPathIncludingSourceByRecordID(
start_data_source_code,
start_record_id,
end_data_source_code,
end_record_id,
max_degree,
excluded_entities_as_json,
required_dsrcs_as_json,
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":
[]
}
],
"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": 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
}
]
}
]
}