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: creating a composition to establish your dynamic results feed (you only need to do this once) and creating composition rules for defining how to insert smart groups into the results feed.Create compositions
Compositions help you compose dynamic result feeds with more control. To create your first composition:- 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).
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_collections
attribute. - Save the group and then the composition rule to apply it.
-
Specify the conditions for triggering your composition rule, for example, search queries, categories, collections and contexts.
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.
Client-generated secured API keys aren’t supported for the Composition API.
-
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
index
widget. - 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.