> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure your search

> Tailor Algolia for Salesforce B2C Commerce to your needs.

export const Index = () => <Tooltip tip="An Algolia index is a searchable dataset that consists of records and configuration settings. These settings define how the records are searched and ranked.">
    index
  </Tooltip>;

After [synchronizing your data to Algolia](/doc/integration/salesforce-commerce-cloud-b2c/getting-started/start-indexing-your-data),
configure your search for optimal relevancy.

You can do this in the [Algolia dashboard](https://dashboard.algolia.com), on the details page of your indices.
You should see your newly created indices, with the following naming pattern:

* `${hostname}__${site-id}__products__${locale}`
* `${hostname}__${site-id}__categories__${locale}`
* `${hostname}__${site-id}__contents__${locale}` (optional)

The total number of indices created depends on the number of locales your site supports.

<img src="https://mintcdn.com/algolia/rjtfW1hxW88XnUWE/doc/integration/salesforce-commerce-cloud-b2c/getting-started/indices-created-by-algolia-cartridge.png?fit=max&auto=format&n=rjtfW1hxW88XnUWE&q=85&s=fc7b9fd1f6948ec96ba079408766a38b" alt="Screenshot of a table showing two indices with labels 'hostname', 'site ID', and 'locale' highlighting their respective values." width="951" height="206" data-path="doc/integration/salesforce-commerce-cloud-b2c/getting-started/indices-created-by-algolia-cartridge.png" />

When you assign Algolia cartridges to a site, they automatically support all the locales the site uses.
You can customize the list of locales with the `Locales for indexing` [custom preference](/doc/integration/salesforce-commerce-cloud-b2c/getting-started/custom-preferences) or the `localesForIndexing` job step parameter.

<Warning>
  Indexing many locales can [affect runtime](/doc/integration/salesforce-commerce-cloud-b2c/guides/performance-considerations#number-of-currencies-and-locales-affects-run-time).
</Warning>

## Configure your searchable attributes

Decide which attributes to make searchable when setting up your <Index />.
Add them in the **Configuration > Searchable attributes** section of the dashboard.
For more information, see [Searchable attributes](/doc/guides/managing-results/must-do/searchable-attributes).

To begin with, consider adding the following attributes: `categoryPageId`, `name`, `short_description`, and `long_description`.

<img src="https://mintcdn.com/algolia/rjtfW1hxW88XnUWE/doc/integration/salesforce-commerce-cloud-b2c/getting-started/searchable-attributes.png?fit=max&auto=format&n=rjtfW1hxW88XnUWE&q=85&s=e0a2ee6b9dad004974c041c9bee95078" alt="Screenshot of the 'Searchable attributes' section with a list of attributes and an input field to add more." width="1389" height="636" data-path="doc/integration/salesforce-commerce-cloud-b2c/getting-started/searchable-attributes.png" />

## Configure your facets

Define the attributes you want to be available as [facets](/doc/guides/managing-results/refine-results/faceting) in the **Configuration > Facets** tab on the Algolia dashboard.
You should add at least the following attributes:

* The Algolia cartridges support all the currencies your site uses. The `price` attribute relates to each currency. For example, if your site is using USD and EUR, add `price.USD` and `price.EUR`.
* `__primary_category.0`, `__primary_category.1`, `__primary_category.2` to show the category hierarchy in the search results.
* `categoryPageId` to create [category pages](/doc/guides/solutions/ecommerce/browse/tutorials/category-pages/).
* Facets relevant to your products, such as `brand`, `size`, and `color`.

<Info>
  The actual facets depend on your attribute names and your [record model](/doc/integration/salesforce-commerce-cloud-b2c/indexing/product-indexing/indexing-attributes#record-models).
  For example, if you choose the base product-level or attribute-sliced record model, some facets would become `variants.price.USD`, `variants.size`, `variants.color`.
</Info>

<img src="https://mintcdn.com/algolia/rjtfW1hxW88XnUWE/doc/integration/salesforce-commerce-cloud-b2c/getting-started/configure-facets.png?fit=max&auto=format&n=rjtfW1hxW88XnUWE&q=85&s=27cbb9845eb66f7f4d92f4c6be8f5c6f" alt="Screenshot of the 'Configure your search' page, showing the 'Facets' section with attributes like '__primary_category.0' and 'brand', each with a 'not searchable' drop-down menu and delete icon." width="1042" height="759" data-path="doc/integration/salesforce-commerce-cloud-b2c/getting-started/configure-facets.png" />

Different category levels are represented by the corresponding `__primary_category` attributes.
These attributes are suitable for [hierarchical faceting](/doc/guides/managing-results/refine-results/faceting#hierarchical-facets)
in Algolia, such as `Women > Dresses > Evening Dresses`: `__primary_category.0`, `__primary_category.1`, and `__primary_category.2`.

<Info>
  With faceting, Algolia offers capabilities that are similar to [Salesforce product variation grouping](https://help.salesforce.com/s/articleView?id=sf.comm_var_group_overview.htm\&type=5).
</Info>

## Configure results grouping

Results are grouped by default when you use the **[Base product](/doc/integration/salesforce-commerce-cloud-b2c/indexing/product-indexing/indexing-attributes#base-product-record-example)** or the **[Attribute-sliced](/doc/integration/salesforce-commerce-cloud-b2c/indexing/product-indexing/indexing-attributes#attribute-sliced-record-example)** record model.

For the **[Variation product](/doc/integration/salesforce-commerce-cloud-b2c/indexing/product-indexing/indexing-attributes#variation-product-record-example)** record model, if your catalog is large, it's common practice to [group](/doc/guides/managing-results/refine-results/grouping) related variants in the results by displaying *one* result per base product.
To do that:

* Add the `masterID` attribute to the list of **Additional Product Attributes**.
* [Enable the `distinct` feature](/doc/guides/sending-and-managing-data/prepare-your-data/how-to/indexing-long-documents) on the `masterID` attribute.

<Tip>
  If you enable results grouping,
  you should add [color swatches](/doc/integration/salesforce-commerce-cloud-b2c/building-the-search-ui/front-end#display-color-swatches) so users can see the different color variations.
</Tip>

## Configure your replicas

You can use [replicas](/doc/guides/managing-results/refine-results/sorting/in-depth/replicas) to let your users sort search results in different ways,
such as sorting by price in ascending and descending order.
To create the replicas for sorting on price:

1. Select your products index and go to **Replicas**.

2. Create two replicas:

   * `hostname__site-id__products__price_USD_asc`
   * `hostname__site-id__products__price_USD_desc`

   <img src="https://mintcdn.com/algolia/rjtfW1hxW88XnUWE/doc/integration/salesforce-commerce-cloud-b2c/getting-started/replicas.png?fit=max&auto=format&n=rjtfW1hxW88XnUWE&q=85&s=cf4f498db6e2fbd4be597b5b3ea6ee6c" alt="Screenshot of the 'Replicas' section in the Algolia dashboard, showing a list of existing replica indices and a button to 'Create Replica Index'." width="1039" height="571" data-path="doc/integration/salesforce-commerce-cloud-b2c/getting-started/replicas.png" />

   This adds two new indices to your app.

   <img src="https://mintcdn.com/algolia/rjtfW1hxW88XnUWE/doc/integration/salesforce-commerce-cloud-b2c/getting-started/new-replicas.png?fit=max&auto=format&n=rjtfW1hxW88XnUWE&q=85&s=f32b778567c4922086f02e0ff74ae5e6" alt="Screenshot of the 'Indices' page showing a list of indices with two newly created replicas highlighted and labeled 'User newly created replicas.'" width="1029" height="715" data-path="doc/integration/salesforce-commerce-cloud-b2c/getting-started/new-replicas.png" />

3. Configure each replica to sort by price.

   <img src="https://mintcdn.com/algolia/rjtfW1hxW88XnUWE/doc/integration/salesforce-commerce-cloud-b2c/getting-started/replicas-sorting-config.png?fit=max&auto=format&n=rjtfW1hxW88XnUWE&q=85&s=2251b3e5b36446b19e363343a4bb303e" alt="Screenshot of the 'Replicas' config page showing 'price. USD' as the sort-by attribute and a warning about no custom ranking." width="1090" height="794" data-path="doc/integration/salesforce-commerce-cloud-b2c/getting-started/replicas-sorting-config.png" />

You can add as many replicas as you need,
depending on the number of locales your site supports or other sorting strategies you want to offer.
Just make sure your usage of Algolia falls within the limits of your plan.
