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
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3530738-support-configurable-shards.patch | 2.53 KB | thebrokenbrain |
Issue fork search_api_opensearch-3530738
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
thebrokenbrainComment #4
thebrokenbrainComment #5
thebrokenbrainComment #6
thebrokenbrainComment #7
gooddenis commentedThe patch works for me, thx!
Comment #11
fraserthompsonUpdated to apply to 3.x and 2.x. I also changed the behavior so it only applies the setting if its defined, rather than assuming defaults (we should let the OpenSearch cluster define the defaults).
This is an especially important MR for the AWS OpenSearch Service since it uses 5 shards by default, which won't be appropriate for smaller use cases.