Пример #1
0
    def show_stats(self, index_name):
        """
        Display performance metrics for specified index.
        """
        es = self.es_connection.get_connection()
        result = es.indices.stats(index_name)

        # Print an error if one occurred
        acknowledge_result(result)
Пример #2
0
    def show_stats(self, index_name):
        """
        Display performance metrics for specified index.
        """
        es = self.es_connection.get_connection()
        result = es.indices.stats(index_name)

        # Print an error if one occurred
        acknowledge_result(result)
Пример #3
0
    def delete_index(self, index_name):
        """
        Delete an ElasticSearch index
            index_name      Name of index to be deleted
        """
        es = self.es_connection.get_connection()
        result = es.indices.delete(index=index_name)

        # Display error if there is one
        acknowledge_result(result)
Пример #4
0
    def open_index(self, index_name):
        """
        Open a closed index in the ElasticSearch cluster
            index_name      Name of index to be opened
        """
        es = self.es_connection.get_connection()
        result = es.indices.open(index=index_name)

        # Display error if there is one
        acknowledge_result(result)
Пример #5
0
    def close_index(self, index_name):
        """
        Close an index on the ElasticSearch cluster
            index_name      Name of index to be closed
        """
        es = self.es_connection.get_connection()
        result = es.indices.close(index=index_name)

        # Print an error if one occurred
        acknowledge_result(result)
Пример #6
0
    def list_index(self, index_name):
        """
        Display a list of indices in the ElasticSearch cluster.
            index_name      Name of index to list (default is _all)
        """
        es = self.es_connection.get_connection()
        result = es.indices.get_settings(index=index_name)

        # Print an error if one occurred
        acknowledge_result(result)
Пример #7
0
    def flush_index(self, index_name):
        """
        Flush all of the documents out of the target index
            index_name      Name of index to be flushed
        """
        es = self.es_connection.get_connection()
        result = es.indices.flush(index=index_name)

        # Print an error if one occurred
        acknowledge_result(result)
Пример #8
0
    def close_index(self, index_name):
        """
        Close an index on the ElasticSearch cluster
            index_name      Name of index to be closed
        """
        es = self.es_connection.get_connection()
        result = es.indices.close(index=index_name)

        # Print an error if one occurred
        acknowledge_result(result)
Пример #9
0
    def open_index(self, index_name):
        """
        Open a closed index in the ElasticSearch cluster
            index_name      Name of index to be opened
        """
        es = self.es_connection.get_connection()
        result = es.indices.open(index=index_name)

        # Display error if there is one
        acknowledge_result(result)
Пример #10
0
    def delete_index(self, index_name):
        """
        Delete an ElasticSearch index
            index_name      Name of index to be deleted
        """
        es = self.es_connection.get_connection()
        result = es.indices.delete(index=index_name)

        # Display error if there is one
        acknowledge_result(result)
Пример #11
0
    def flush_index(self, index_name):
        """
        Flush all of the documents out of the target index
            index_name      Name of index to be flushed
        """
        es = self.es_connection.get_connection()
        result = es.indices.flush(index=index_name)

        # Print an error if one occurred
        acknowledge_result(result)
Пример #12
0
    def list_index(self, index_name):
        """
        Display a list of indices in the ElasticSearch cluster.
            index_name      Name of index to list (default is _all)
        """
        es = self.es_connection.get_connection()
        result = es.indices.get_settings(index=index_name)

        # Print an error if one occurred
        acknowledge_result(result)
Пример #13
0
    def delete_alias(self, alias_name, index_name):
        """
        Delete the specified alias from ElasticSearch.
            alias_name      The alias name to delete
            index_name      The index that the alias points to
        """
        es = self.es_connection.get_connection()
        result = es.indices.delete_alias(index=index_name, name=alias_name)

        # Display error if there is one
        acknowledge_result(result)
Пример #14
0
    def list_mapping(self, index_name):
        """
        Show the mappings for a specified index.
            index_name      Index to display mappings.
        """

        es = self.es_connection.get_connection()
        result = es.indices.get_mapping(index=index_name)

        # Display error if there is one
        acknowledge_result(result)
Пример #15
0
    def list_alias(self, index_name):
        """
        List the aliases defined on the ElasticSearch cluster.
            index_name      Name of index to list aliases (default is _all)
        """
        es = self.es_connection.get_connection()
        if not index_name:
            result = es.indices.get_aliases()
        else:
            result = es.indices.get_aliases(index=index_name)

        # Print an error if one occurred
        acknowledge_result(result)
Пример #16
0
    def cluster_health(self, index_name):
        """
        Display basic cluster health information, or if index is specified, of that index.
            index_name      Index to get health status on
        """
        es = self.es_connection.get_connection()
        if index_name == "_all":
            result = es.cluster.health()
        else:
            result = es.cluster.health(index=index_name)

        # Print an error if one occurred
        acknowledge_result(result)
Пример #17
0
    def create_alias(self, alias_name, index_name):
        """
        Create an alias to the specified index.
            alias_name      The alias name to create
            index_name      The index the alias points to
        """
        es = self.es_connection.get_connection()
        result = es.indices.put_alias(name=alias_name,
                                      index=index_name,
                                      ignore=400)

        # Display error if there is one
        acknowledge_result(result)
Пример #18
0
    def list_alias(self, index_name):
        """
        List the aliases defined on the ElasticSearch cluster.
            index_name      Name of index to list aliases (default is _all)
        """
        es = self.es_connection.get_connection()
        if not index_name:
            result = es.indices.get_aliases()
        else:
            result = es.indices.get_aliases(index=index_name)

        # Print an error if one occurred
        acknowledge_result(result)
Пример #19
0
    def delete_alias(self, alias_name, index_name):
        """
        Delete the specified alias from ElasticSearch.
            alias_name      The alias name to delete
            index_name      The index that the alias points to
        """
        es = self.es_connection.get_connection()
        result = es.indices.delete_alias(
            index=index_name,
            name=alias_name
        )

        # Display error if there is one
        acknowledge_result(result)
Пример #20
0
    def create_alias(self, alias_name, index_name):
        """
        Create an alias to the specified index.
            alias_name      The alias name to create
            index_name      The index the alias points to
        """
        es = self.es_connection.get_connection()
        result = es.indices.put_alias(
            name=alias_name,
            index=index_name,
            ignore=400
        )

        # Display error if there is one
        acknowledge_result(result)
Пример #21
0
    def create_index(self, index_name, shards, replicas):
        """
        Create an ElasticSearch index
            index_name      Name of index to be created
            shards          Number of shards for index
            replicas        Number of replicas for index
        """
        es = self.es_connection.get_connection()
        result = es.indices.create(
            index=index_name,
            body={
                'settings': {
                    'number_of_shards': shards,
                    'number_of_replicas': replicas
                }
            },
            # Do not generate an error if index exists
            ignore=400)

        # Display error if there is one
        acknowledge_result(result)
Пример #22
0
    def create_index(self, index_name, shards, replicas):
        """
        Create an ElasticSearch index
            index_name      Name of index to be created
            shards          Number of shards for index
            replicas        Number of replicas for index
        """
        es = self.es_connection.get_connection()
        result = es.indices.create(
            index=index_name,
            body={
                'settings': {
                    'number_of_shards': shards,
                    'number_of_replicas' : replicas
                }
            },
            # Do not generate an error if index exists
            ignore=400
        )

        # Display error if there is one
        acknowledge_result(result)