AWS Lambda mapping a search query into controlled vocabulary filters and a fulltext query using ITA Taxonomy API.
Example query: the United States and pacific rim contracting in oceania malasia pacifico cuba in scuba
response:
{
'filters': {
'country': ['Cuba', 'United States'],
'world_region': ['Oceania', 'Pacific Rim']
},
'query': 'the and contracting in malasia pacifico in scuba'
}- This project is tested against Python 3.7+ in CircleCI.
- Make sure you have your Trade.gov API Key handy.
git clone git@github.com:GovWizely/lambda-semantic-query-service.git
cd lambda-semantic-query-service
mkvirtualenv -p /usr/local/bin/python3.8 -r requirements-test.txt lambda-semantic-query-serviceIf you are using PyCharm, make sure you enable code compatibility inspections for Python 3.7/3.8.
python -m pytest- Define the Taxonomies API key as an environment variable
export TAXONOMIES_API_KEY=your_key. - Define AWS credentials in either
config.yamlor in the [default] section of~/.aws/credentials. To use another profile, you can do something likeexport AWS_DEFAULT_PROFILE=govwizely. - Edit
config.yamlif you want to specify a different AWS region, role, and so on. - Make sure you do not commit the AWS credentials to version control.
lambda invoke -v
In the AWS Lambda console, set up the TAXONOMIES_API_KEY environment variable. Then you are ready to deploy:
lambda deploy --requirements requirements.txt