> ## 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 commercetools sources for Algolia

> Configure the sources for Algolia's commercetools integration.

export const Records = () => <Tooltip tip="A record is a searchable object in an Algolia index. Each record consists of named attributes." cta="Algolia records" href="/doc/guides/sending-and-managing-data/prepare-your-data#algolia-records">
    records
  </Tooltip>;

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>;

## Configure your data source

A **source** defines how to authenticate with your commercetools project,
and which store and languages you want to index.

In the **Configure your data source** form,
paste the [curl command from your commercetools API client](/doc/integration/commercetools/get-started/installation#create-a-commercetools-api-client). This automatically fills the form with details about your commercetools project and creates an authentication method.

<img src="https://mintcdn.com/algolia/hAsVAHDvpFee-pZL/doc/integration/commercetools/get-started/ct-curl-input.jpg?fit=max&auto=format&n=hAsVAHDvpFee-pZL&q=85&s=d18ccb1288f6601d7bc5db5ff25752a2" alt="Screenshot of a form field labeled 'curl command' with placeholder text to paste a commercetools-provided command." width="1528" height="688" data-path="doc/integration/commercetools/get-started/ct-curl-input.jpg" />

If you want to enter custom information, manually fill the form.

<img src="https://mintcdn.com/algolia/OE79PcXc4TKi8BZa/doc/integration/commercetools/get-started/ct-form-source.jpg?fit=max&auto=format&n=OE79PcXc4TKi8BZa&q=85&s=b5d64d280b1dd33fee0398caf99c3ad6" alt="Screenshot of a form to configure a commercetools data source with fields for API URL, Project Key, Store, Fallback stock value, and Name." width="1576" height="1624" data-path="doc/integration/commercetools/get-started/ct-form-source.jpg" />

This form includes the following information:

* **OAuth 2.0** authentication so that Algolia can connect to your commercetools project.
* **API URL** and **Project Key** to identify which project to fetch.
* **Store** and **Languages** to index.
* **Fallback stock value** which determines which value is stored in the Algolia record if there is no inventory information about the product.

Select the commercetools store you want to index.
Under **Languages**, select one or more product data languages for your store.

After filling the form, click **Create source** to set up the source.

### Product query predicate

The [product query predicate](https://docs.commercetools.com/api/predicates/query#on-product-attributes)
is an **optional** filter that gets appended to the [product-projection endpoint in commercetools' API](https://docs.commercetools.com/api/projects/productProjections#query-productprojections)
when fetching product information.
Only products returned by the commercetools API after applying this filter are indexed.

For example:

* `variants(prices(value(centAmount < 20000)))`: index products that have at least one variant with a price less than 200.
* `masterVariant(attributes(name="Brand" and value="Algolia"))`: index products for which the `Brand` attribute is `Algolia`.

## Configure your destination

A **destination** defines where and how the data will be stored in the Algolia indices.

<img src="https://mintcdn.com/algolia/OE79PcXc4TKi8BZa/doc/integration/commercetools/get-started/ct-form-destination.jpg?fit=max&auto=format&n=OE79PcXc4TKi8BZa&q=85&s=8ff037c6868f67e1298034696b405af3" alt="Screenshot of the 'Configure your destination' form with fields for index, credentials, record type, and attribute exclusion." width="1582" height="1770" data-path="doc/integration/commercetools/get-started/ct-form-destination.jpg" />

After selecting an <Index /> name and providing the credentials,
choose if you want to index products or product-variants:

* **Product**. A record is assigned to each product.
* **Variant**. A record is assigned to each [product variant](https://docs.commercetools.com/learning-composable-commerce-administrator/product-modeling/products).

<Tip>
  For more information about:

  * The <Records /> schema for each option, see [Product schema](/doc/integration/commercetools/indexing/product-schema)
  * Which model best suits your needs, see [Ecommerce records](/doc/guides/sending-and-managing-data/prepare-your-data/how-to/ecommerce-records).
</Tip>

Finally, you can add a list of attributes you want to exclude from your records.

Finish setting up the destination by clicking **Create destination**.

## Configure your tasks

A **task** is the link between source and destination.
You run tasks to launch the indexing process.

<img src="https://mintcdn.com/algolia/OE79PcXc4TKi8BZa/doc/integration/commercetools/get-started/ct-form-task.jpg?fit=max&auto=format&n=OE79PcXc4TKi8BZa&q=85&s=29e12fcdee45b444738ef9721d3850a3" alt="Screenshot of a 'Configure your task' form with two selected options: 'On demand' and 'Subscription', and a 'Failure Threshold (%)' slider set to 0." width="1528" height="1096" data-path="doc/integration/commercetools/get-started/ct-form-task.jpg" />

The commercetools integration creates two tasks:

* An **On demand** task that you can use to trigger a full reindex of your products.

  The task has a **Failure Threshold** setting that lets you specify a percentage of allowed indexing failures.
  For example, a failure threshold of 10% requires 90% of your records to import without errors.

* A **Subscription** task that automatically updates indexes when a product changes and is published in commercetools.

  The **Subscription** task has two options:

  * **Partial record updates.**
    Only attributes coming from commercetools are updated in the existing records.
    If your records have attributes added from another source, they won't be updated.
    If a record doesn't exist, it will be added.

  * **Full record updates.**
    The existing records are replaced with commercetools records
    (see [Product schema](/doc/integration/commercetools/indexing/product-schema)).
    If a record doesn't exist, it will be added.

Click **Create task** to finish setup.

You can choose when to index your products.
Click **Run** to immediately start indexing your commercetools products.

<img src="https://mintcdn.com/algolia/OE79PcXc4TKi8BZa/doc/integration/commercetools/get-started/ct-launch-reindex.jpg?fit=max&auto=format&n=OE79PcXc4TKi8BZa&q=85&s=c993120faac781fa1cbbed8108508ff3" alt="Screenshot of a dialog box asking to trigger a full reindex, with 'Cancel' and 'Run' buttons." width="1226" height="430" data-path="doc/integration/commercetools/get-started/ct-launch-reindex.jpg" />

<Info>
  You won't see your products in your Algolia index until you trigger a full reindex.
</Info>

## Trigger a full reindex

After installing a commercetools connector,
you need to trigger a full reindex at least once.

You should also reindex if you changed,
added, or deleted a source or a destination.

To trigger a full reindex,
run the **On demand** task by clicking **Run task**:

<img src="https://mintcdn.com/algolia/OE79PcXc4TKi8BZa/doc/integration/commercetools/get-started/ct-run-task.jpg?fit=max&auto=format&n=OE79PcXc4TKi8BZa&q=85&s=a5642511948628c10bb6c345461216c3" alt="Screenshot of two icons: a play button and a vertical ellipsis, within a user interface." width="67" height="40" data-path="doc/integration/commercetools/get-started/ct-run-task.jpg" />

Confirm by clicking **Run**.

<img src="https://mintcdn.com/algolia/OE79PcXc4TKi8BZa/doc/integration/commercetools/get-started/ct-manual-reindex.jpg?fit=max&auto=format&n=OE79PcXc4TKi8BZa&q=85&s=eb54d527a00168a626e9ea3d227ecb57" alt="Screenshot of a confirmation dialog asking 'Are you sure you want to launch a new run from this task configuration?' with 'Cancel' and 'Run' buttons." width="1212" height="382" data-path="doc/integration/commercetools/get-started/ct-manual-reindex.jpg" />

To check the progress and status of your reindex run,
go to the [Connector Debugger](https://dashboard.algolia.com/connectors/debugger) in the Algolia dashboard.
