Posts

Showing posts from 2019

Elastic Search - Open and Close all Indices using python

If you are using Elastic Search and need to Close all indices this python script does it for you. It also provides the option to open all indices as well ! #!/usr/bin/env python import json import simplejson import urllib.request as request import sys import time ###################################################################### # Usage: # Set the elasticsearch_addr in the file, (this can be externalized) # - NGINX URL which point to ElasticSearch with Auth Header # python <filename>.py close # python <filename>.py open # ###################################################################### elasticsearch_addr = "http://NGINX-POINTS-TO-ELASTICSEARCH:80" def fetch_document_list_with_status () : # URL to fetch all indices request_url = elasticsearch_addr + '/' + '_cat/indices?format=json&pretty=true' response = request.urlopen(request_url) json_data = simplej...