Coder Social home page Coder Social logo

elasticsearch-haystack's People

Contributors

silvanocerza avatar

Watchers

 avatar

Forkers

kavichu

elasticsearch-haystack's Issues

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

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.