This approach is deprecated. For new implementations, use Smart Groups with external sources instead.Smart Groups offer:
- Built-in deduplication. Algolia automatically removes duplicates between sponsored and organic results.
- Simplified implementation. Less custom merge logic required on your backend.
- Flexible placement. Control exact positions for sponsored items.
- Optional re-ranking. Apply Algolia’s relevance ranking to sponsored products.
How the RMP first strategy works
- User performs a search (for example, “running shoes”).
- Your app queries the RMP for a list of sponsored product IDs.
- Your app sends two queries to Algolia:
- One query fetches product records for the sponsored items.
- The other query fetches regular search results.
- Your app merges these results, removes duplicates, and injects sponsored items at specific positions.
- The combined list of regular and sponsored results is sent to the frontend for display.
Requirements
To effectively implement the RMP first strategy, the RMP’s API must return unique product identifiers. These are ideallyobjectID
s that align with your Algolia index.
If an Algolia objectID
isn’t available, your identifier must reliably select the appropriate Algolia records.
Pros
- Consistent product information. Because the product details for sponsored and regular results come from Algolia, users always see consistent and up-to-date product information.
- Simpler deduplication. Since all product data comes from Algolia, merging and deduplication is straightforward.
Cons
- Slower than the parallel requests strategy. Because the Algolia multi-query must wait until the RMP call finishes, the response time is slower than the parallel request strategy.
Example
JavaScript
How the code works
- Call the RMP. The
fetchRetailMediaWithTimeout
function requests a list of sponsored product IDs from the RMP. If the request times out, it returns null. - Algolia multi-query request. Sends a multi-query to Algolia, requesting detailed information for sponsored and regular products.
- Merge and deduplicate. The
injectSponsoredProducts
function removes any duplicates between the two sets of results and inserts sponsored items at specified positions. - Return merged results. The frontend receives the merged list, where sponsored products are appropriately labeled.
Before your strategy goes live, ensure you’ve considered the regulatory requirements and the influence of sponsored results on your analytics, ranking, and UI.