Support configurable shards and replicas in Search API OpenSearch module

Created on 18 June 2025, about 2 months ago

Problem/Motivation

Currently, when an index is created using the Search API OpenSearch module, the number of shards and replicas is set using default OpenSearch values. These settings can significantly impact performance, resilience, and storage usage, especially in larger or more complex deployments.

There is no way to configure the number of shards and replicas from the administrative UI, which forces developers to override this via external index management.

Allowing these values to be configurable through the Drupal UI would give site administrators more control over the indexing behavior and make the module more flexible in production scenarios.

Steps to reproduce

1. Install and enable the search_api_opensearch module.
2. Create a new Search API index using the OpenSearch backend.
3. Observe that there is no option to set the number of shards or replicas in the configuration form.
4. The index is created with default OpenSearch settings (usually 1 shard and 1 replica).

Proposed resolution

Add two new configuration fields to the OpenSearch index configuration form:
- Number of shards
- Number of replicas

These settings should be passed to OpenSearch when the index is created via the API, using the appropriate OpenSearch index settings.

Defaults can be provided (e.g., 1 shard, 1 replica), but the user should be able to override them via the UI.

Remaining tasks

Update the code that creates the OpenSearch index to include number_of_shards and number_of_replicas settings.

User interface changes

Two new number fields in the OpenSearch backend configuration form:
- Number of shards
- Number of replicas

✨ Feature request
Status

Active

Version

2.4

Component

Code

Created by

🇪🇸Spain thebrokenbrain Las Palmas de Gran Canaria

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024