Before you begin
- Your Algolia app must use Algolia’s dynamic scaling infrastructure. If your app uses the classic infrastructure, Algolia needs to migrate it. Check with your Customer Success Manager.
- You need to have access to Merchandising Studio to curate the results.
- Your app needs to have the Smart Groups feature and Composition API enabled, according to your plan. If you think you should have access to these features, but you don’t see them available, contact your Account Manager or Customer Success Manager.
- You need to integrate a new API called the Composition API with InstantSearch for the web or with API clients. For details, see Set up your integration.
Rollout and rollback considerations
- Test your implementation on development and testing instances before going to production.
- For A/B testing, consider using replica indices that you use with compositions with and without inserted groups, and then have A/B analytics associated with these indices. Native composition A/B testing is not supported yet.
- Keep your original Search API implementation alongside your Compositions API implementation. This provides an easy rollback option if the Compositions API doesn’t meet your needs.
Create your groups in the Merchandising Studio
Creating groups involves two steps:1
Create a composition
Compositions help you compose dynamic result feeds with more control.To create your first composition:
Create one composition per index.
If you have different sites, for example, for different geographical regions,
create one composition per site and index,
such as “Product results feed - US”.
Each composition can have rules for the insertion of groups.
If you have 5 sites and one product index each, you need 5 compositions.
Give each composition a short, descriptive, and unique name, and select its main source index.After creating your first composition,
you can find it in the Search all compositions and indices menu.
To list all your compositions and create new ones,
go to the Compositions section in the sidebar and click All Compositions.
- Go to the Merchandising Studio and open the Merch tools page.
-
Select the Search all compositions and indices menu and click + Create Composition.

- In the New Composition menu, enter a name for this dynamic results feed, and optionally a description. Select which main index should be associated with this results feed.

If you have different sorting strategies,
you also need one composition for each replica (for example, sorted by price from high to low).
2
Create composition rules
To insert a curated group of results for a specific query, category page or collection, define and publish a composition rule.
- Use the Index and Compositions selector to select the relevant composition. Go to the Merchandising Studio’s Merch tools > Compositions > Composition Rules page.
In addition to creating and editing Composition Rules in the Merch tools section,
you can also use the Visual Merchandiser as an entry point,
with the benefit of managing both Composition and Index Rules in a visual, streamlined workflow.
To do this,
go to the Merchandising Studio’s Visual Merchandiser,
select the relevant Composition and search query, category, or collection
and then click Actions on the top right.
- Click + New Composition Rule.
-
In the compositions rules editor, you can configure where to insert your groups given specific conditions,
and based on which filters match the group results.
- Specify the conditions for triggering your composition rule, for example, search queries, categories, collections and contexts.
You can select several queries, categories, and collections if you want to inject the same groups for them.
- Add the groups you would like to create. Select Algolia Index as the data source, then use filters with ‘and’ as well as ‘or’ operations to curate the items that should appear in the group. Specify the group’s starting position in the results, as well as the number of matching records to include.
To add a group from a collection, filter on the
_collectionsattribute.- Save the group and then the composition rule to apply it.
Creating and managing compositions and composition rules is only available through the Merchandising Studio.
It’s not yet supported through the HTTP APIs, API clients, or the Algolia dashboard.
Curate groups
You can curate groups further, that is, change the behavior of the query used to retrieve and rank the group’s items, by applying Index Rules to it (for example, for a group with promoted Adidas items, the group’s sub-query might be query=“shoes” and filter: “brand”=“Adidas”).To learn more about the difference between Composition Rules and Index Rules,
see Composition Rules and Index Rules.
- Go to Merchandising Studio’s Visual Merchandiser.
- Select the corresponding Composition and Search query/Category/Collection where the group’s Composition Rule is applied.
- Click Actions > Curate “group name” (or find the group in the visual preview, click the three dots, then select “Curate group”).
- The Index Rule Visual Editor will open, allowing you to define Consequences (for example pin or hide items) for the group’s sub-query.
- Publish the Index Rule.
The final results might be different to the ones shown in the Index Rules preview, due to the deduplication between the main query and groups. For example, an item might already be part of a previous group and thus not show in the final results in a later group. You may see more items than the ones shown in the final group, when there are more items that match the criteria than the quantity or length of the group is.
Integrate compositions
Integrating compositions and smart groups involves these steps:- In the Algolia dashboard, go to Settings > API Keys and copy your application ID and API key. The API key needs at least search permissions for the index used in your composition.
-
In the Merchandising Studio, go to Merch tools > Compositions > Composition Rules and select the composition from the “Composition or Index” selector. Copy the composition ID to your clipboard.

- Integrate the frontend using one of the integration methods below to query the Composition API (with API clients or InstantSearch for web).
Integrate compositions with API clients
Use the Composition API client in one of the supported programming languages.Swift is not supported yet.
The Shopify, Magento, BigCommerce, and Salesforce CommerceCloud (default) frontend integrations don’t yet support the Compositions API.
Integrate compositions with InstantSearch
Start by replacing the Search API client with the Composition API client. Compositions require these versions of the InstantSearch libraries:- React InstantSearch: version 7.15.5 or later
- InstantSearch.js: version 4.78.1 or later
- Vue InstantSearch: version 4.20.6 or later
- InstantSearch iOS and InstantSearch Android aren’t supported.
- You can’t use the
indexwidget. - Combining Composition API and Search API or Recommend API calls on the same page is not supported.
- The Autocomplete UI library is not yet supported. You can’t show groups in autocomplete menus, but you can launch a composition-based search results page from there.
React InstantSearch
React
InstantSearch.js
JavaScript
Vue InstantSearch
Vue
Facets (including disjunctive faceting)
Retrieving a list of facet values for a facet you’re filtering on is called disjunctive faceting. The Composition API natively supports disjunctive faceting. When querying the Composition API, you can annotate any facet with thedisjunctive modifier to get the correct response in a single API request.
For example:
JavaScript
InstantSearch handles this automatically.
Events setup
When sending click and conversion events, you still need to send the underlying index name asindexName attribute with your events,
not the composition ID.
No further changes are needed.
InstantSearch’s out-of-box events tracking mechanism handles passing the underlying index name for you,
if you’re using the specified versions of the packages.
Next steps
Curate group results
You can still create index rules for pinning, hiding, boosting, or burying results, or to add banners, in combination with composition rules (for example, in the Visual Merchandiser page, or in Merch tools > Ranking Factors > Rules). Index rules are triggered for the group subquery used to retrieve the best matching records. For more information about how this subquery is formed, see Composition rules and index rules. You can set up an index rule that triggers for the same query, context, or applied filters, to curate the group results, for example, to pin or hide items. The index rule is applied when the group results are retrieved.Groups and Dynamic Re-Ranking
If enabled on your index, Dynamic Re-Ranking applies to the main results and group subqueries. In other words, the items included in a group are also re-ranked if Dynamic Re-Ranking is turned on for that subquery.Groups and sorting
You can set up a composition for your replica index. Then, you can curate the replica feed like a standard results feed.More than one group
By default, groups insert into the final results feed at the specified start position. You can’t have two groups with the same start position. If the specified start position of a group overlaps with positions already taken up by another group with a higher start position, the group is inserted at the next available positions that are not yet taken up by a preceding group at query time. For example, if you have a group A of 3 products configured for start position 1 and a group B of 3 products for position 2, the final results will have products A.1, A.2, A.3, B.1, B.2, B.3 in the first 6 positions, with the main results starting in position 7.Deduplication
Algolia automatically deduplicates results across and group results to ensure each item appears only once. By default, Algolia uses thehighestInjected strategy, which prioritises items in their injected group positions over organic results.
You can configure the deduplication strategy when creating composition rules to control how duplicates are resolved. For detailed information about available strategies and how to configure them, see Deduplication strategy.