from elasticsearch import Elasticsearch
from elasticsearch.exceptions import NotFoundError
from datetime import datetime
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('-u')
parser.add_argument('-p')
args = parser.parse_args()
user = args.u
pwd = args.p


def get_index_statistics(es, index_name):
    all_index_info = es.indices.stats(index=index_name)
    relevant_index_info = {
        "index_name": index_name,
        "number_of_shards": all_index_info["_shards"]["total"],
        "number_of_primaries_documents": all_index_info["_all"]["primaries"]["docs"]["count"],
        "number_of_total_documents": all_index_info["_all"]["total"]["docs"]["count"],
        "total_index_size_in_bytes": all_index_info["_all"]["total"]["store"]["size_in_bytes"]
    }
    print(relevant_index_info)


es = Elasticsearch(hosts=['localhost'], port=9200, http_auth=(user, pwd))
index_name = "daily_news-{}".format(datetime.today().date())
try:
    get_index_statistics(es, index_name=index_name)
except NotFoundError as e:
    print(f"ERROR: The index {index_name} is not exists yet, insert data and try again")

f30f82524f97926a6280481068b765aa3797a558
<mask token>


def get_index_statistics(es, index_name):
    all_index_info = es.indices.stats(index=index_name)
    relevant_index_info = {'index_name': index_name, 'number_of_shards':
        all_index_info['_shards']['total'], 'number_of_primaries_documents':
        all_index_info['_all']['primaries']['docs']['count'],
        'number_of_total_documents': all_index_info['_all']['total']['docs'
        ]['count'], 'total_index_size_in_bytes': all_index_info['_all'][
        'total']['store']['size_in_bytes']}
    print(relevant_index_info)


<mask token>

<mask token>
parser.add_argument('-u')
parser.add_argument('-p')
<mask token>


def get_index_statistics(es, index_name):
    all_index_info = es.indices.stats(index=index_name)
    relevant_index_info = {'index_name': index_name, 'number_of_shards':
        all_index_info['_shards']['total'], 'number_of_primaries_documents':
        all_index_info['_all']['primaries']['docs']['count'],
        'number_of_total_documents': all_index_info['_all']['total']['docs'
        ]['count'], 'total_index_size_in_bytes': all_index_info['_all'][
        'total']['store']['size_in_bytes']}
    print(relevant_index_info)


<mask token>
try:
    get_index_statistics(es, index_name=index_name)
except NotFoundError as e:
    print(
        f'ERROR: The index {index_name} is not exists yet, insert data and try again'
        )

<mask token>
parser = argparse.ArgumentParser()
parser.add_argument('-u')
parser.add_argument('-p')
args = parser.parse_args()
user = args.u
pwd = args.p


def get_index_statistics(es, index_name):
    all_index_info = es.indices.stats(index=index_name)
    relevant_index_info = {'index_name': index_name, 'number_of_shards':
        all_index_info['_shards']['total'], 'number_of_primaries_documents':
        all_index_info['_all']['primaries']['docs']['count'],
        'number_of_total_documents': all_index_info['_all']['total']['docs'
        ]['count'], 'total_index_size_in_bytes': all_index_info['_all'][
        'total']['store']['size_in_bytes']}
    print(relevant_index_info)


es = Elasticsearch(hosts=['localhost'], port=9200, http_auth=(user, pwd))
index_name = 'daily_news-{}'.format(datetime.today().date())
try:
    get_index_statistics(es, index_name=index_name)
except NotFoundError as e:
    print(
        f'ERROR: The index {index_name} is not exists yet, insert data and try again'
        )

from elasticsearch import Elasticsearch
from elasticsearch.exceptions import NotFoundError
from datetime import datetime
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-u')
parser.add_argument('-p')
args = parser.parse_args()
user = args.u
pwd = args.p


def get_index_statistics(es, index_name):
    all_index_info = es.indices.stats(index=index_name)
    relevant_index_info = {'index_name': index_name, 'number_of_shards':
        all_index_info['_shards']['total'], 'number_of_primaries_documents':
        all_index_info['_all']['primaries']['docs']['count'],
        'number_of_total_documents': all_index_info['_all']['total']['docs'
        ]['count'], 'total_index_size_in_bytes': all_index_info['_all'][
        'total']['store']['size_in_bytes']}
    print(relevant_index_info)


es = Elasticsearch(hosts=['localhost'], port=9200, http_auth=(user, pwd))
index_name = 'daily_news-{}'.format(datetime.today().date())
try:
    get_index_statistics(es, index_name=index_name)
except NotFoundError as e:
    print(
        f'ERROR: The index {index_name} is not exists yet, insert data and try again'
        )

from elasticsearch import Elasticsearch
from elasticsearch.exceptions import NotFoundError
from datetime import datetime
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('-u')
parser.add_argument('-p')
args = parser.parse_args()
user = args.u
pwd = args.p


def get_index_statistics(es, index_name):
    all_index_info = es.indices.stats(index=index_name)
    relevant_index_info = {
        "index_name": index_name,
        "number_of_shards": all_index_info["_shards"]["total"],
        "number_of_primaries_documents": all_index_info["_all"]["primaries"]["docs"]["count"],
        "number_of_total_documents": all_index_info["_all"]["total"]["docs"]["count"],
        "total_index_size_in_bytes": all_index_info["_all"]["total"]["store"]["size_in_bytes"]
    }
    print(relevant_index_info)


es = Elasticsearch(hosts=['localhost'], port=9200, http_auth=(user, pwd))
index_name = "daily_news-{}".format(datetime.today().date())
try:
    get_index_statistics(es, index_name=index_name)
except NotFoundError as e:
    print(f"ERROR: The index {index_name} is not exists yet, insert data and try again")
