Algolia Search Provider
Configure Algolia as search provider with webhooks and indexing details.
Webhook-based search configuration
Creating and updating products
5
Configure the transformation mapping
/**
* @param webhook the webhook object
* @param webhook.method destination method. Allowed values: "POST", "PUT"
* @param webhook.url current destination address
* @param webhook.eventType current webhook Event Type
* @param webhook.payload JSON payload
* @param webhook.cancel whether to cancel dispatch of the given webhook
*/
function handler(webhook) {
// modify the webhook object...
// and return it
return webhook
}curl "https://${APPLICATION_ID}.algolia.net/1/indexes/contacts/myID" \
-X PUT \
-H "X-Algolia-API-Key: ${API_KEY}" \
-H "X-Algolia-Application-Id: ${APPLICATION_ID}" \
-d '{
"name": "Betty Jane Mccamey",
"company": "Vita Foods Inc.",
"email": "betty@mccamey.com"
}'/**
* @param webhook the webhook object
* @param webhook.method destination method. Allowed values: "POST", "PUT"
* @param webhook.url current destination address
* @param webhook.eventType current webhook Event Type
* @param webhook.payload JSON payload
* @param webhook.cancel whether to cancel dispatch of the given webhook
*/
function handler(webhook) {
webhook.method = "PUT";
return webhook
}/**
* @param webhook the webhook object
* @param webhook.method destination method. Allowed values: "POST", "PUT"
* @param webhook.url current destination address
* @param webhook.eventType current webhook Event Type
* @param webhook.payload JSON payload
* @param webhook.cancel whether to cancel dispatch of the given webhook
*/
function handler(webhook) {
var indexName = "emporix_" + webhook.payload.siteCode;
webhook.url = webhook.url + "/" + indexName + "/" + webhook.payload.id;
webhook.method = "PUT";
return webhook
}
/**
* @param webhook the webhook object
* @param webhook.method destination method. Allowed values: "POST", "PUT"
* @param webhook.url current destination address
* @param webhook.eventType current webhook Event Type
* @param webhook.payload JSON payload
* @param webhook.cancel whether to cancel dispatch of the given webhook
*/
function handler(webhook) {
if(webhook.payload.medias && webhook.payload.medias.length > 0) {
webhook.payload.image = webhook.payload.medias[0].url;
}
var indexName = "emporix_" + webhook.payload.siteCode;
webhook.url = webhook.url + "/" + indexName + "/" + webhook.payload.id;
webhook.method = "PUT";
return webhook
}Deleting products
5
Configure the transformation mapping
curl -X DELETE \
-H "X-Algolia-API-Key: ${API_KEY}" \
-H "X-Algolia-Application-Id: ${APPLICATION_ID}" \
"https://${APPLICATION_ID}.algolia.net/1/indexes/contacts/myID"/**
* @param webhook the webhook object
* @param webhook.method destination method. Allowed values: "POST", "PUT"
* @param webhook.url current destination address
* @param webhook.eventType current webhook Event Type
* @param webhook.payload JSON payload
* @param webhook.cancel whether to cancel dispatch of the given webhook
*/
function handler(webhook) {
webhook.method = "DELETE";
return webhook
}/**
* @param webhook the webhook object
* @param webhook.method destination method. Allowed values: "POST", "PUT"
* @param webhook.url current destination address
* @param webhook.eventType current webhook Event Type
* @param webhook.payload JSON payload
* @param webhook.cancel whether to cancel dispatch of the given webhook
*/
function handler(webhook) {
var indexName = "emporix_" + webhook.payload.siteCode;
webhook.url = webhook.url + "/" + indexName + "/" + webhook.payload.id;
webhook.method = "DELETE";
return webhook
}Indexing output by strategy
Last updated
Was this helpful?




