How to set up Raptor Search Personalization in Algolia

PS -

To sort Algolia’s search results based on personalized products, brands and categories, use “Optional Filters” in Algolia 

This is done clientside in Javascript in relation to setting up the searches. 

 Read more about Optional Filters here: 



When setting up, the flow must be as follows:  

  1. When a user enters the site, Raptor is called. (serverside or clientside through your own server as proxy). 
  1. The results must be available clientside, so they can be injected into Algolia Search at every search.  


Example with CategoryId 

API call for raptor{apikey}?CookieId=8750B8F4-0FFF-9080-F27B-8891EB303AAA&json=true 

xxxx = insert customerId 

Gives the followingresult:  




Where resultsFromRaptor = { results:[{"CategoryId":"A","Score":"2.153985"},{"CategoryId":"B","Score":"1.441762"},{"CategoryId":"C","Score":"0.999654"}]}; 


Tranform into Optional Filter array: 

Where categoryfilters ={  

            return `categoryId:${val.CategoryId}<score=${val.Score}>`  



        console.log(categoryfilters); // ["categoryId:A<score=2.153985>", "categoryId:B<score=1.441762>", "categoryId:C<score=0.999654>"] 


And add to search.query:"xxxx", { 

optionalFilters: categoryfilters 



Example with ProductId 

This can also be accomplished without using scores with ProductId’es (scores on productid’s is not necessary as long as they are in the search result.) 


ProductId’s should be an asset in Algolia 




Where productsFromRaptor= {results:[{"productid":"307025005"},{"productid":"307025003"},{"productid":"306001027"},{"productid":"306001026"},{"productid":"307010014"},{"productid":"47200100000"}]}; 


whereproductfilters ={  

            return `productId:${val.productid}`  



        console.log(productfilters); // ["productId:307025005", "productId:307025003", "productId:306001027", "productId:306001026", "productId:307010014", "productId:47200100000"]"xxxx", { 

optionalFilters: productfilters 




If you have any further questions, please reach out to our support at 


Have more questions? Submit a request


Powered by Zendesk