Overview
This is a simple example of how to add and search Senzing via the Python SDK. This requires that the Senzing REST API Server is set up and running.
The easiest way to do this is to have completed the Senzing Quickstart and then deploy SenzingGo which should take less than 15minutes:
# Run the Senzing Quickstart and then from the same shell, still in the project directory, run: $ python3 -m pip install docker $ wget -O python/SenzingGo.py https://raw.githubusercontent.com/Senzing/senzinggo/main/SenzingGo.py $ chmod +x python/SenzingGo.py $ sudo --preserve-env ./python/SenzingGo.py
# Senzing go will output the URL/port that the RESTful API is listening on
For more on the Senzing RESTful API go here.
There are many other options for installing Senzing and the RESTful API (docker-compose, Kubernetes, AWS Cloudformation, AKS, OpenShift, etc) that can be found on the Senzing Community GitHub but SenzingGo is the most simple deployment for someone just trying Senzing out.
Example
Note: Adjust the URL on the commands to match your RESTful API installation.
Entity resolve a record
curl -X 'PUT' \
'http://localhost:8250/data-sources/TEST/records/1?withInfo=false&withRaw=false' \
-H 'accept: application/json; charset=UTF-8' \
-H 'Content-Type: application/json; charset=UTF-8' \
-d '{ "NAME_FULL": "JOHN SMITH", "ADDR_FULL": "123 Main St, Las Vegas NV" }'
Get the entity it resolved to
curl -X 'GET' \
'http://localhost:8250/data-sources/TEST/records/1/entity?featureMode=WITH_DUPLICATES&withFeatureStats=false&withInternalFeatures=false&forceMinimal=false&withRelated=PARTIAL&withRaw=false' \
-H 'accept: application/json; charset=UTF-8'
Search for entities
curl -X 'POST' \
'http://localhost:8250/search-entities?featureMode=WITH_DUPLICATES&withFeatureStats=false&withInternalFeatures=false&forceMinimal=false&withRelationships=false&withRaw=false' \
-H 'accept: application/json; charset=UTF-8' \
-H 'Content-Type: application/json; charset=UTF-8' \
-d '{ "NAME_FIRST": "JANE", "NAME_LAST": "SMITH", "ADDR_FULL": "123 Main St, Las Vegas NV" }'
Comments
0 comments
Please sign in to leave a comment.