G2Engine Searching for Entities
Searching for Entities
searchByAttributes
searchByAttributes()
retrieves entity data based on a user-specified set of entity attributes.
g2_engine.searchByAttributes(data_as_json, response_bytearray, g2_engine_flags)
Parameters
- data_as_json: (str) A JSON document with the attribute data to search for.
- 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 searchByAttributes flags)
Click to expand `searchByAttributes()` 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()
data_as_json = '{"NAME_FULL":"BOB SMITH", "EMAIL_ADDRESS": "bsmith@work.com"}'
response_bytearray = bytearray()
try:
g2_engine.init("G2Engine", senzing_engine_configuration_json)
g2_engine.searchByAttributes(
data_as_json,
response_bytearray)
g2_engine.destroy()
print(response_bytearray.decode())
except G2Exception as err:
print(err)
Output
{
"RESOLVED_ENTITIES":
[
{
"MATCH_INFO":
{
"MATCH_LEVEL": 1,
"MATCH_LEVEL_CODE": "RESOLVED",
"MATCH_KEY": "+NAME+EMAIL",
"ERRULE_CODE": "SF1_CNAME",
"FEATURE_SCORES":
{
"EMAIL":
[
{
"INBOUND_FEAT": "bsmith@work.com",
"CANDIDATE_FEAT": "bsmith@work.com",
"FULL_SCORE": 100
}
],
"NAME":
[
{
"INBOUND_FEAT": "BOB SMITH",
"CANDIDATE_FEAT": "Bob J Smith",
"GNR_FN": 93,
"GNR_SN": -1,
"GNR_GN": -1,
"GENERATION_MATCH": -1,
"GNR_ON": -1
},
{
"INBOUND_FEAT": "BOB SMITH",
"CANDIDATE_FEAT": "Robert Smith",
"GNR_FN": 97,
"GNR_SN": -1,
"GNR_GN": -1,
"GENERATION_MATCH": -1,
"GNR_ON": -1
}
]
}
},
"ENTITY":
{
"RESOLVED_ENTITY":
{
"ENTITY_ID": 1,
"ENTITY_NAME": "Robert Smith",
"FEATURES":
{
"ADDRESS":
[
{
"FEAT_DESC": "1515 Adela Lane Las Vegas NV 89111",
"LIB_FEAT_ID": 34,
"USAGE_TYPE": "HOME",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "1515 Adela Lane Las Vegas NV 89111",
"LIB_FEAT_ID": 34
},
{
"FEAT_DESC": "1515 Adela Ln Las Vegas NV 89132",
"LIB_FEAT_ID": 76
}
]
},
{
"FEAT_DESC": "123 Main Street, Las Vegas NV 89132",
"LIB_FEAT_ID": 3,
"USAGE_TYPE": "MAILING",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "123 Main Street, Las Vegas NV 89132",
"LIB_FEAT_ID": 3
}
]
}
],
"DOB":
[
{
"FEAT_DESC": "11/12/1979",
"LIB_FEAT_ID": 75,
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "11/12/1979",
"LIB_FEAT_ID": 75
}
]
},
{
"FEAT_DESC": "12/11/1978",
"LIB_FEAT_ID": 2,
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "12/11/1978",
"LIB_FEAT_ID": 2
},
{
"FEAT_DESC": "11/12/1978",
"LIB_FEAT_ID": 33
}
]
}
],
"EMAIL":
[
{
"FEAT_DESC": "bsmith@work.com",
"LIB_FEAT_ID": 5,
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "bsmith@work.com",
"LIB_FEAT_ID": 5
}
]
}
],
"NAME":
[
{
"FEAT_DESC": "B Smith",
"LIB_FEAT_ID": 74,
"USAGE_TYPE": "PRIMARY",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "B Smith",
"LIB_FEAT_ID": 74
}
]
},
{
"FEAT_DESC": "Robert Smith",
"LIB_FEAT_ID": 1,
"USAGE_TYPE": "PRIMARY",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "Robert Smith",
"LIB_FEAT_ID": 1
},
{
"FEAT_DESC": "Bob J Smith",
"LIB_FEAT_ID": 55
},
{
"FEAT_DESC": "Bob Smith",
"LIB_FEAT_ID": 32
}
]
}
],
"PHONE":
[
{
"FEAT_DESC": "702-919-1300",
"LIB_FEAT_ID": 4,
"USAGE_TYPE": "HOME",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "702-919-1300",
"LIB_FEAT_ID": 4
}
]
},
{
"FEAT_DESC": "702-919-1300",
"LIB_FEAT_ID": 4,
"USAGE_TYPE": "MOBILE",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "702-919-1300",
"LIB_FEAT_ID": 4
}
]
}
],
"RECORD_TYPE":
[
{
"FEAT_DESC": "PERSON",
"LIB_FEAT_ID": 30,
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "PERSON",
"LIB_FEAT_ID": 30
}
]
}
]
},
"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"
}
}
},
{
"MATCH_INFO":
{
"MATCH_LEVEL": 4,
"MATCH_LEVEL_CODE": "NAME_ONLY",
"MATCH_KEY": "+NAME",
"ERRULE_CODE": "CNAME",
"FEATURE_SCORES":
{
"NAME":
[
{
"INBOUND_FEAT": "BOB SMITH",
"CANDIDATE_FEAT": "Robert E Smith Sr",
"GNR_FN": 90,
"GNR_SN": -1,
"GNR_GN": -1,
"GENERATION_MATCH": -1,
"GNR_ON": -1
},
{
"INBOUND_FEAT": "BOB SMITH",
"CANDIDATE_FEAT": "Robbie Smith",
"GNR_FN": 97,
"GNR_SN": -1,
"GNR_GN": -1,
"GENERATION_MATCH": -1,
"GNR_ON": -1
}
]
}
},
"ENTITY":
{
"RESOLVED_ENTITY":
{
"ENTITY_ID": 5,
"ENTITY_NAME": "Robert E Smith Sr",
"FEATURES":
{
"ADDRESS":
[
{
"FEAT_DESC": "123 E Main St Henderson NV 89132",
"LIB_FEAT_ID": 92,
"USAGE_TYPE": "MAILING",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "123 E Main St Henderson NV 89132",
"LIB_FEAT_ID": 92
}
]
},
{
"FEAT_DESC": "123 Main St, Las Vegas",
"LIB_FEAT_ID": 100003,
"USAGE_TYPE": "MAILING",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "123 Main St, Las Vegas",
"LIB_FEAT_ID": 100003
}
]
}
],
"DOB":
[
{
"FEAT_DESC": "3/31/1954",
"LIB_FEAT_ID": 100002,
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "3/31/1954",
"LIB_FEAT_ID": 100002
}
]
}
],
"DRLIC":
[
{
"FEAT_DESC": "112233 NV",
"LIB_FEAT_ID": 93,
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "112233 NV",
"LIB_FEAT_ID": 93
}
]
}
],
"NAME":
[
{
"FEAT_DESC": "Robert E Smith Sr",
"LIB_FEAT_ID": 100001,
"USAGE_TYPE": "PRIMARY",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "Robert E Smith Sr",
"LIB_FEAT_ID": 100001
},
{
"FEAT_DESC": "Robbie Smith",
"LIB_FEAT_ID": 91
}
]
}
],
"RECORD_TYPE":
[
{
"FEAT_DESC": "PERSON",
"LIB_FEAT_ID": 30,
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "PERSON",
"LIB_FEAT_ID": 30
}
]
}
]
},
"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"
}
}
},
{
"MATCH_INFO":
{
"MATCH_LEVEL": 4,
"MATCH_LEVEL_CODE": "NAME_ONLY",
"MATCH_KEY": "+NAME",
"ERRULE_CODE": "CNAME",
"FEATURE_SCORES":
{
"EMAIL":
[
{
"INBOUND_FEAT": "bsmith@work.com",
"CANDIDATE_FEAT": "robert.smith@email.com",
"FULL_SCORE": 0
}
],
"NAME":
[
{
"INBOUND_FEAT": "BOB SMITH",
"CANDIDATE_FEAT": "Robert Smith",
"GNR_FN": 97,
"GNR_SN": -1,
"GNR_GN": -1,
"GENERATION_MATCH": -1,
"GNR_ON": -1
}
]
}
},
"ENTITY":
{
"RESOLVED_ENTITY":
{
"ENTITY_ID": 100003,
"ENTITY_NAME": "Robert Smith",
"FEATURES":
{
"EMAIL":
[
{
"FEAT_DESC": "robert.smith@email.com",
"LIB_FEAT_ID": 100044,
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "robert.smith@email.com",
"LIB_FEAT_ID": 100044
}
]
}
],
"NAME":
[
{
"FEAT_DESC": "Robert Smith",
"LIB_FEAT_ID": 1,
"USAGE_TYPE": "PRIMARY",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "Robert Smith",
"LIB_FEAT_ID": 1
}
]
}
],
"RECORD_TYPE":
[
{
"FEAT_DESC": "PERSON",
"LIB_FEAT_ID": 30,
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "PERSON",
"LIB_FEAT_ID": 30
}
]
}
]
},
"RECORD_SUMMARY":
[
{
"DATA_SOURCE": "WATCHLIST",
"RECORD_COUNT": 1,
"FIRST_SEEN_DT": "2022-12-16 23:01:37.158",
"LAST_SEEN_DT": "2022-12-16 23:01:37.158"
}
],
"LAST_SEEN_DT": "2022-12-16 23:01:37.158"
}
}
}
]
}
searchByAttributesV3
searchByAttributesV3()
retrieves entity data based on a user-specified set of entity attributes and a specified search profile. This allows searches to use different generics thresholds. Please contact support@senzing.com for details on creating a custom search profile.
g2_engine.searchByAttributesV3(data_as_json, search_profile, response_bytearray, g2_engine_flags)
Parameters
- data_as_json: (str) A JSON document with the attribute data to search for.
- search_profile: (str) A configured search profile name.
- 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 searchByAttributes flags)
Click to expand `searchByAttributesV3()` 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()
data_as_json = '{"NAME_FULL":"BOB SMITH", "EMAIL_ADDRESS": "bsmith@work.com"}'
search_profile = 'SEARCH'
response_bytearray = bytearray()
try:
g2_engine.init("G2Engine", senzing_engine_configuration_json)
g2_engine.searchByAttributesV3(
data_as_json,
search_profile,
response_bytearray)
g2_engine.destroy()
print(response_bytearray.decode())
except G2Exception as err:
print(err)
Output
{
"RESOLVED_ENTITIES":
[
{
"MATCH_INFO":
{
"MATCH_LEVEL": 1,
"MATCH_LEVEL_CODE": "RESOLVED",
"MATCH_KEY": "+NAME+EMAIL",
"ERRULE_CODE": "SF1_CNAME",
"FEATURE_SCORES":
{
"EMAIL":
[
{
"INBOUND_FEAT": "bsmith@work.com",
"CANDIDATE_FEAT": "bsmith@work.com",
"FULL_SCORE": 100
}
],
"NAME":
[
{
"INBOUND_FEAT": "BOB SMITH",
"CANDIDATE_FEAT": "Bob J Smith",
"GNR_FN": 93,
"GNR_SN": -1,
"GNR_GN": -1,
"GENERATION_MATCH": -1,
"GNR_ON": -1
},
{
"INBOUND_FEAT": "BOB SMITH",
"CANDIDATE_FEAT": "Robert Smith",
"GNR_FN": 97,
"GNR_SN": -1,
"GNR_GN": -1,
"GENERATION_MATCH": -1,
"GNR_ON": -1
}
]
}
},
"ENTITY":
{
"RESOLVED_ENTITY":
{
"ENTITY_ID": 1,
"ENTITY_NAME": "Robert Smith",
"FEATURES":
{
"ADDRESS":
[
{
"FEAT_DESC": "1515 Adela Lane Las Vegas NV 89111",
"LIB_FEAT_ID": 34,
"USAGE_TYPE": "HOME",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "1515 Adela Lane Las Vegas NV 89111",
"LIB_FEAT_ID": 34
},
{
"FEAT_DESC": "1515 Adela Ln Las Vegas NV 89132",
"LIB_FEAT_ID": 76
}
]
},
{
"FEAT_DESC": "123 Main Street, Las Vegas NV 89132",
"LIB_FEAT_ID": 3,
"USAGE_TYPE": "MAILING",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "123 Main Street, Las Vegas NV 89132",
"LIB_FEAT_ID": 3
}
]
}
],
"DOB":
[
{
"FEAT_DESC": "11/12/1979",
"LIB_FEAT_ID": 75,
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "11/12/1979",
"LIB_FEAT_ID": 75
}
]
},
{
"FEAT_DESC": "12/11/1978",
"LIB_FEAT_ID": 2,
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "12/11/1978",
"LIB_FEAT_ID": 2
},
{
"FEAT_DESC": "11/12/1978",
"LIB_FEAT_ID": 33
}
]
}
],
"EMAIL":
[
{
"FEAT_DESC": "bsmith@work.com",
"LIB_FEAT_ID": 5,
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "bsmith@work.com",
"LIB_FEAT_ID": 5
}
]
}
],
"NAME":
[
{
"FEAT_DESC": "B Smith",
"LIB_FEAT_ID": 74,
"USAGE_TYPE": "PRIMARY",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "B Smith",
"LIB_FEAT_ID": 74
}
]
},
{
"FEAT_DESC": "Robert Smith",
"LIB_FEAT_ID": 1,
"USAGE_TYPE": "PRIMARY",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "Robert Smith",
"LIB_FEAT_ID": 1
},
{
"FEAT_DESC": "Bob J Smith",
"LIB_FEAT_ID": 55
},
{
"FEAT_DESC": "Bob Smith",
"LIB_FEAT_ID": 32
}
]
}
],
"PHONE":
[
{
"FEAT_DESC": "702-919-1300",
"LIB_FEAT_ID": 4,
"USAGE_TYPE": "HOME",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "702-919-1300",
"LIB_FEAT_ID": 4
}
]
},
{
"FEAT_DESC": "702-919-1300",
"LIB_FEAT_ID": 4,
"USAGE_TYPE": "MOBILE",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "702-919-1300",
"LIB_FEAT_ID": 4
}
]
}
],
"RECORD_TYPE":
[
{
"FEAT_DESC": "PERSON",
"LIB_FEAT_ID": 30,
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "PERSON",
"LIB_FEAT_ID": 30
}
]
}
]
},
"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"
}
}
},
{
"MATCH_INFO":
{
"MATCH_LEVEL": 4,
"MATCH_LEVEL_CODE": "NAME_ONLY",
"MATCH_KEY": "+NAME",
"ERRULE_CODE": "CNAME",
"FEATURE_SCORES":
{
"NAME":
[
{
"INBOUND_FEAT": "BOB SMITH",
"CANDIDATE_FEAT": "Robert E Smith Sr",
"GNR_FN": 90,
"GNR_SN": -1,
"GNR_GN": -1,
"GENERATION_MATCH": -1,
"GNR_ON": -1
},
{
"INBOUND_FEAT": "BOB SMITH",
"CANDIDATE_FEAT": "Robbie Smith",
"GNR_FN": 97,
"GNR_SN": -1,
"GNR_GN": -1,
"GENERATION_MATCH": -1,
"GNR_ON": -1
}
]
}
},
"ENTITY":
{
"RESOLVED_ENTITY":
{
"ENTITY_ID": 5,
"ENTITY_NAME": "Robert E Smith Sr",
"FEATURES":
{
"ADDRESS":
[
{
"FEAT_DESC": "123 E Main St Henderson NV 89132",
"LIB_FEAT_ID": 92,
"USAGE_TYPE": "MAILING",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "123 E Main St Henderson NV 89132",
"LIB_FEAT_ID": 92
}
]
},
{
"FEAT_DESC": "123 Main St, Las Vegas",
"LIB_FEAT_ID": 100003,
"USAGE_TYPE": "MAILING",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "123 Main St, Las Vegas",
"LIB_FEAT_ID": 100003
}
]
}
],
"DOB":
[
{
"FEAT_DESC": "3/31/1954",
"LIB_FEAT_ID": 100002,
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "3/31/1954",
"LIB_FEAT_ID": 100002
}
]
}
],
"DRLIC":
[
{
"FEAT_DESC": "112233 NV",
"LIB_FEAT_ID": 93,
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "112233 NV",
"LIB_FEAT_ID": 93
}
]
}
],
"NAME":
[
{
"FEAT_DESC": "Robert E Smith Sr",
"LIB_FEAT_ID": 100001,
"USAGE_TYPE": "PRIMARY",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "Robert E Smith Sr",
"LIB_FEAT_ID": 100001
},
{
"FEAT_DESC": "Robbie Smith",
"LIB_FEAT_ID": 91
}
]
}
],
"RECORD_TYPE":
[
{
"FEAT_DESC": "PERSON",
"LIB_FEAT_ID": 30,
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "PERSON",
"LIB_FEAT_ID": 30
}
]
}
]
},
"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"
}
}
},
{
"MATCH_INFO":
{
"MATCH_LEVEL": 4,
"MATCH_LEVEL_CODE": "NAME_ONLY",
"MATCH_KEY": "+NAME",
"ERRULE_CODE": "CNAME",
"FEATURE_SCORES":
{
"EMAIL":
[
{
"INBOUND_FEAT": "bsmith@work.com",
"CANDIDATE_FEAT": "robert.smith@email.com",
"FULL_SCORE": 0
}
],
"NAME":
[
{
"INBOUND_FEAT": "BOB SMITH",
"CANDIDATE_FEAT": "Robert Smith",
"GNR_FN": 97,
"GNR_SN": -1,
"GNR_GN": -1,
"GENERATION_MATCH": -1,
"GNR_ON": -1
}
]
}
},
"ENTITY":
{
"RESOLVED_ENTITY":
{
"ENTITY_ID": 100003,
"ENTITY_NAME": "Robert Smith",
"FEATURES":
{
"EMAIL":
[
{
"FEAT_DESC": "robert.smith@email.com",
"LIB_FEAT_ID": 100044,
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "robert.smith@email.com",
"LIB_FEAT_ID": 100044
}
]
}
],
"NAME":
[
{
"FEAT_DESC": "Robert Smith",
"LIB_FEAT_ID": 1,
"USAGE_TYPE": "PRIMARY",
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "Robert Smith",
"LIB_FEAT_ID": 1
}
]
}
],
"RECORD_TYPE":
[
{
"FEAT_DESC": "PERSON",
"LIB_FEAT_ID": 30,
"FEAT_DESC_VALUES":
[
{
"FEAT_DESC": "PERSON",
"LIB_FEAT_ID": 30
}
]
}
]
},
"RECORD_SUMMARY":
[
{
"DATA_SOURCE": "WATCHLIST",
"RECORD_COUNT": 1,
"FIRST_SEEN_DT": "2022-12-16 23:01:37.158",
"LAST_SEEN_DT": "2022-12-16 23:01:37.158"
}
],
"LAST_SEEN_DT": "2022-12-16 23:01:37.158"
}
}
}
]
}