Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elasticsearch indices to be created with number_of_replicas as default as 0. #1

Open
AmirSabjan opened this issue Apr 23, 2024 · 0 comments

Comments

@AmirSabjan
Copy link

Description:

Currently, Elasticsearch indices created through Haystack use the default cluster setting of 1 replica shard. For Haystack deployments, it's desirable to have the option to create indices with 0 replicas to optimize resource utilisation.

Proposed Change:

Modify Haystack's self._client.indices.create(index=index, body=settings) call to accept a parameter specifying the desired number of replicas. This parameter should then be incorporated into the settings body passed to the Elasticsearch API.

Example Code:

Python

class ElasticsearchDocumentStore:
    def __init__(self, *, hosts: Optional[Hosts] = None, index: str = "default", number_of_replicas=0, **kwargs):
 
      """
        Creates an Elasticsearch index with the specified number of replicas.
      
        Args:
            index (str): The name of the index to create.
            number_of_replicas (int, optional): The desired number of replicas for the index. Defaults to 0.
        """
        settings = {
            "number_of_replicas": number_of_replicas
        }
        if not self._client.indices.exists(index=index):
          self._client.indices.create(index=index, body=settings)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant