This Module is a deep integration with Swell and Algolia allowing you to rank, facet and replicate
This module deploys to AWS Lambda
You'll need serverless to run this and a AWS account or other provider
npm install -g serverless
set a .env
file
SWELL_STORE_ID=***
SWELL_SECRET_KEY=***
ALGOLIA_INDEX=swell_products
ALGOLIA_APP_ID=***
ALGOLIA_ADMIN_API_KEY=***
Update the Algolia config (algolia.config.json
) to what you need for your project.
Field | Description |
---|---|
defaultRanking |
The ranking of your default index ALGOLIA_INDEX |
rankings |
The individual rankings for using sort, will create a seperate replica per ranking |
searchableAttributes |
Algolia searchable Attributes |
attributesForFaceting |
Algolia Facetable Attributes |
{
"defaultRanking": ["desc(name)"],
"rankings": [
{
"suffix": "price_desc",
"ranking": [
"desc(price)"
]
},
{
"suffix": "price_asc",
"ranking": [
"desc(price)"
]
}
],
"searchableAttributes": ["name"],
"attributesForFaceting": ["attribute.brand", "categories"]
}
The commands below will deploy the serverless function to AWS then create the indexes
sls deploy
sls invoke --function init
sls invoke --function reindex
sls invoke --function init
will create the replicas based on your algolia.config.json
sls invoke --function reindex
will pull all the products into Algolia
Developer > Webhooks > Add Webhook
And create a webhook as so:
Replace my-serverless-domain
with your cloudfront, or route53 domain generated from serverless on deploy
Replace stage
with your environment stage so something like dev
or prod