---
title: How to set up Raptor Search Recommendation in Algolia
description: 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 searche
---

[Skip to content](https://content.raptorservices.com/help-center/how-to-set-up-raptor-search-personalization-in-algolia#main-content)

![raptor-qntm-logo\_horizontal\_gradient.png\]](https://content.raptorservices.com/hs-fs/hubfs/raptor-qntm-logo_horizontal_gradient.png?height=40&name=raptor-qntm-logo_horizontal_gradient.png)

Open main navigation

Close main navigation

- [Go to raptorservices.com](https://raptorservices.com/)

[Go to raptorservices.com](https://raptorservices.com/)

 Hello. How can we help you?

- There are no suggestions because the search field is empty.

1. [Help Center](https://content.raptorservices.com/help-center?hsLang=en)
2. [Site Search](https://content.raptorservices.com/help-center/site-search?hsLang=en)
3. [Search Ranking & Recommendations](https://content.raptorservices.com/help-center/site-search?hsLang=en#search-ranking-recommendations)

# How to set up Raptor Search Recommendation in Algolia

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: 

1. [https://www.algolia.com/doc/api-reference/api-parameters/optionalFilters/](https://www.algolia.com/doc/api-reference/api-parameters/optionalFilters/)
2. [https://www.algolia.com/doc/guides/managing-results/rules/merchandising-and-promoting/in-depth/optional-filters/](https://www.algolia.com/doc/guides/managing-results/rules/merchandising-and-promoting/in-depth/optional-filters/)

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).
2. The results must be available clientside, so they can be injected into Algolia Search at every search.

### Example with CategoryId

**API call for raptor:**  

[https://api.raptorsmartadvisor.com/v1/](https://api.raptorsmartadvisor.com/v1/xxxx/GetSearchPersonalCategoryIds/10/%7bapikey%7d?CookieId=8750B8F4-0FFF-9080-F27B-8891EB303AAA&json=true)   

 xxxx/GetSearchPersonalCategoryIds/10/{apikey}?CookieId=8750B8F4-0FFF-9080-F27B-8891EB303AAA&json=true

   
\* xxxx = insert customerId   
 

**Gives the following result:**   

```
[{"CategoryId":"A","Score":"2.153985"},{"CategoryId":"B","Score":"1.441762"},{"CategoryId":"C","Score":"0.999654"}]  
```

  

**Clientside:**  

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  = 

```
resultsFromRaptor.results.map(function(val){               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:  

```
algolia.search("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.  

**Example:**     
[https://api.raptorsmartadvisor.com/v1/\[InsertCustomerid\]/GetSearchPersonalProductIds/10/{apikey}?CookieId=8750B8F4-0FFF-9080-F27B-8891EB303AAA&json=true&select=ProductId](https://api.raptorsmartadvisor.com/v1/xxxx/GetSearchPersonalProductIds/10/%7bapikey%7d?CookieId=8750B8F4-0FFF-9080-F27B-8891EB303AAA&json=true&select=ProductId)  

  

Where productsFromRaptor=

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

where productfilters = 

```
productsFromRaptor.results.map(function(val){               return `productId:${val.productid}`           });     console.log(productfilters); // ["productId:307025005", "productId:307025003", "productId:306001027", "productId:306001026", "productId:307010014", "productId:47200100000"] 
```

      

  

If you have any further questions, please reach out to our support at [support@raptorsmartadvisor.com](mailto:support@raptorsmartadvisor.com). 

 

- [Welcome to Raptor](https://content.raptorservices.com/help-center/welcome-to-raptor?hsLang=en#main-content)

    - [Introduction](https://content.raptorservices.com/help-center/welcome-to-raptor?hsLang=en#introduction)
- [Analytics & Insights](https://content.raptorservices.com/help-center/analytics-insights?hsLang=en)
- [Data Management](https://content.raptorservices.com/help-center/data-management?hsLang=en#main-content)

    - [Implementing Tracking](https://content.raptorservices.com/help-center/data-management?hsLang=en#implementing-tracking)
    - [Implementing Raptor Recommendation](https://content.raptorservices.com/help-center/data-management?hsLang=en#implementing-raptor-recommendation)
    - [Email Marketing Integration](https://content.raptorservices.com/help-center/data-management?hsLang=en#email-marketing-integration)
    - [The Data Manager](https://content.raptorservices.com/help-center/data-management?hsLang=en#the-data-manager)
    - [Streaming API](https://content.raptorservices.com/help-center/data-management?hsLang=en#streaming-api)
    - [Destinations](https://content.raptorservices.com/help-center/data-management?hsLang=en#destinations)
- [Customer Data Platform](https://content.raptorservices.com/help-center/customer-data-platform?hsLang=en#main-content)

    - [Introduction](https://content.raptorservices.com/help-center/customer-data-platform?hsLang=en#introduction)
    - [Profile Unification](https://content.raptorservices.com/help-center/customer-data-platform?hsLang=en#profile-unification)
    - [Audience Builder](https://content.raptorservices.com/help-center/customer-data-platform?hsLang=en#audience-builder)
    - [Audience Insights](https://content.raptorservices.com/help-center/customer-data-platform?hsLang=en#audience-insights)
    - [Calculated Attributes](https://content.raptorservices.com/help-center/customer-data-platform?hsLang=en#calculated-attributes)
    - [Activations](https://content.raptorservices.com/help-center/customer-data-platform?hsLang=en#activations)
    - [Single Customer View](https://content.raptorservices.com/help-center/customer-data-platform?hsLang=en#single-customer-view)
    - [CDP Export API](https://content.raptorservices.com/help-center/customer-data-platform?hsLang=en#cdp-export-api)
- [Website Recommendations](https://content.raptorservices.com/help-center/website-recommendations?hsLang=en#main-content)

    - [Introduction](https://content.raptorservices.com/help-center/website-recommendations?hsLang=en#introduction)
    - [Recommendation Strategies](https://content.raptorservices.com/help-center/website-recommendations?hsLang=en#recommendation-strategies)
    - [Feeds](https://content.raptorservices.com/help-center/website-recommendations?hsLang=en#feeds)
    - [Tuning Parameters](https://content.raptorservices.com/help-center/website-recommendations?hsLang=en#tuning-parameters)
    - [Working with the Raptor API](https://content.raptorservices.com/help-center/website-recommendations?hsLang=en#working-with-the-raptor-api)
- [Mail Recommendations](https://content.raptorservices.com/help-center/mail-recommendations?hsLang=en)
- [E-mail Triggers](https://content.raptorservices.com/help-center/e-mail-triggers?hsLang=en#main-content)

    - [Get started](https://content.raptorservices.com/help-center/e-mail-triggers?hsLang=en#get-started)
    - [E-mail Trigger Documentation](https://content.raptorservices.com/help-center/e-mail-triggers?hsLang=en#e-mail-trigger-documentation)
    - [E-mail trigger integrations](https://content.raptorservices.com/help-center/e-mail-triggers?hsLang=en#e-mail-trigger-integrations)
- [Site Search](https://content.raptorservices.com/help-center/site-search?hsLang=en#main-content)

    - [Search Tracking](https://content.raptorservices.com/help-center/site-search?hsLang=en#search-tracking)
    - [Introduction](https://content.raptorservices.com/help-center/site-search?hsLang=en#introduction)
    - [Implementing Site Search](https://content.raptorservices.com/help-center/site-search?hsLang=en#implementing-site-search)
    - [Search Ranking & Recommendations](https://content.raptorservices.com/help-center/site-search?hsLang=en#search-ranking-recommendations)
    - [Reporting](https://content.raptorservices.com/help-center/site-search?hsLang=en#reporting)
- [Merchandising](https://content.raptorservices.com/help-center/merchandising?hsLang=en#main-content)

    - [Introduction to Merchandising](https://content.raptorservices.com/help-center/merchandising?hsLang=en#introduction-to-merchandising)
    - [Boosted Campaigns](https://content.raptorservices.com/help-center/merchandising?hsLang=en#boosted-campaigns)
    - [Customized Feeds](https://content.raptorservices.com/help-center/merchandising?hsLang=en#customized-feeds)
- [AI Models](https://content.raptorservices.com/help-center/ai-models?hsLang=en#main-content)

    - [Customer Lifetime Value](https://content.raptorservices.com/help-center/ai-models?hsLang=en#customer-lifetime-value)
- [Administration](https://content.raptorservices.com/help-center/administration?hsLang=en#main-content)

    - [Trust Center](https://content.raptorservices.com/help-center/administration?hsLang=en#trust-center)
    - [User Management](https://content.raptorservices.com/help-center/administration?hsLang=en#user-management)
    - [Operational Insights](https://content.raptorservices.com/help-center/administration?hsLang=en#operational-insights)
    - [Data Retention](https://content.raptorservices.com/help-center/administration?hsLang=en#data-retention)

[![Raptor Services](https://content.raptorservices.com/hubfs/Logo%20_By%20Ibexa%20-%20Color-Raptor.svg "Raptor Services")](https://www.raptorservices.com/)

raptorsmartadvisor.com Help Center

<https://www.linkedin.com/company/raptorservices/mycompany/> <https://www.instagram.com/raptorservices/>

Copyright © 2026, Raptor Services A/S