> For the complete documentation index, see [llms.txt](https://developer.emporix.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.emporix.io/ce/system-management/search/indexing.md).

# Indexing Service

The Indexing Service is responsible for including all your resources, such as products, or categories, in the search index and make them searchable on your storefront.\
You have to enable your own indexing service on Emporix by providing your credentials for the index provider into the Commerce Engine platform. The supported index providers are [Algolia](https://www.algolia.com/) and [BatteryIncluded](https://batteryincluded.ai/). Only one provider can be active per tenant at a time.

For complete provider-specific setup and examples, see:

<table data-card-size="large" data-view="cards"><thead><tr><th align="center"></th><th align="center"></th><th align="center"></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td align="center"><i class="fa-magnifying-glass">:magnifying-glass:</i></td><td align="center"><strong>Algolia Search Provider</strong></td><td align="center">Set up Algolia webhook endpoints, transformations, and indexing strategy outputs.</td><td></td><td></td><td><a href="/pages/FWq2sumB8Ep73ic0jGiY">/pages/FWq2sumB8Ep73ic0jGiY</a></td></tr><tr><td align="center"><i class="fa-battery-full">:battery-full:</i></td><td align="center"><strong>BatteryIncluded Search Provider</strong></td><td align="center">Configure BatteryIncluded webhook and native indexing service options in one place.</td><td></td><td></td><td><a href="/pages/Q5vDLD8zroJ3I6atBO6L">/pages/Q5vDLD8zroJ3I6atBO6L</a></td></tr></tbody></table>

The Indexing Service gives you the possibility to provide your own API keys to the indexing provider, separately for each tenant. This approach gives you more flexibility in configuration.

There are two groups of endpoints in the Indexing Service - secured and public endpoints:

* **Secured endpoints** - require a security scope and are used for managing configuration.
* **Public endpoints** - do not require any security scopes and can be used directly on a storefront.

{% hint style="warning" %}
Even though the public endpoints do not require scopes, an authorization token is required to complete the request.
{% endhint %}

## Reindexing data

Be aware that changing configuration for indexing provider isn't enough to apply your changes in the index. Usually, the indexing process of your data is triggered by changes done on your products, or dependant entities, such as category, price, media etc. There is a scheduler job that discovers the delta changes on the resource data and starts reindexing of the updated instances, so that they are searchable on the storefront.\
Applying the changes done to the search index configuration require updating all existing product data. To avoid updating all the data, there is a reindexing mechanism available. So, if you change the index configuration, remember to reindex all your product data by using the `reindex` endpoint.

For example, after switching to the **MERGE** strategy with BatteryIncluded as the active provider, run a full reindex to push existing products to BatteryIncluded in the updated document format:

```bash
curl --location 'https://api.emporix.io/indexing/{tenant}/reindex' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer {token}' \
  --data-raw '{
    "mode": "FULL"
  }'
```

## Indexing strategies

As Emporix is a multi-site solution, data on each site may differ, such as `availability` or `price`. Therefore, site-aware data must be included in the index. The Indexing Service provides two index strategies:

* **SPLIT**: The default strategy. The strategy creates as many indices as the number of sites declared in the system. The index item does not contain `sitePrices` and `siteAvailabilities` fields. All the site-aware fields are available on the root level. This approach may be more flexible as a particular index contains only information related to one site. But, the fields that are not site-aware, like `description`, `name` etc are duplicated across all the indices. The number of indices is significantly higher.
* **MERGE**: An alternative strategy. The strategy creates just a single index that contains information from all the sites. The site-aware information is stored in `sitePrices` and `siteAvailabilities` properties. These properties are maps where a key corresponds to a site code and a value corresponds to the `price` or `availability` object respectively. This approach is more performant as you have only one index.

### Changing index strategy

To change the index strategy, use Emporix API and send the request to the Configuration Service.

If there is an already existing configuration for your tenant, send a [Updating a configuration](https://developer.emporix.io/api-references-1/readme/api-reference-8/tenant-configurations#put-configuration-tenant-configurations-propertykey) (`PUT`) request. If there is no configuration yet, first send a [Creating configurations](https://developer.emporix.io/api-references-1/readme/api-reference-8/tenant-configurations#post-configuration-tenant-configurations) (`POST`) request to create one.

If there is no configuration, the SPLIT strategy is used by default.

{% hint style="danger" %}
Propagating changes to the index strategy may take up to 1 hour, so you might not be able to see the changes instantly.
{% endhint %}

<details>

<summary>Example request with SPLIT strategy</summary>

```curl

curl --location --request PUT 'https://api.emporix.io/configuration/{TENANT}/configurations/indexing_siteAwareFieldsStrategy' --header 'authorization: Bearer {TOKEN}' --header 'Content-Type: application/json' --data-raw '{
    "key": "indexing_siteAwareFieldsStrategy",
    "value": {
        "strategy": "SPLIT"
    }
}'

```

</details>

<details>

<summary>Example request with MERGE strategy</summary>

```curl

curl --location --request PUT 'https://api.emporix.io/configuration/{TENANT}/configurations/indexing_siteAwareFieldsStrategy' --header 'authorization: Bearer {TOKEN}' --header 'Content-Type: application/json' --data-raw '{
    "key": "indexing_siteAwareFieldsStrategy",
    "value": {
        "strategy": "MERGE"
    }
}'

```

</details>

{% hint style="info" %}

* Looking for API tutorials? Check out [Indexing Service Tutorial](/api-references/api-guides/configuration/indexing-service/indexing.md).
* Looking for API reference? Check out the [Indexing Service](/api-references/api-guides/configuration/indexing-service.md) in the Emporix API Reference.
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developer.emporix.io/ce/system-management/search/indexing.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
