Last active
April 7, 2020 14:28
-
-
Save rpong/22c8e64bbb29c351f015 to your computer and use it in GitHub Desktop.
optimize all cores in a given solr instance. Sample Usage: ./optimizeSolr.py http://solr1:8970
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# Sample Usage: ./optimizeSolr.py http://solr1:8970 | |
import xml.etree.ElementTree as ET; | |
import requests; | |
import time; | |
import sys; | |
if len(sys.argv) > 1 : | |
rootSolrUrl = sys.argv[1]; | |
r = requests.get(rootSolrUrl + '/solr/admin/cores'); | |
root = ET.fromstring(r.content); | |
for child in root[3]: | |
coreName = child.get('name'); | |
rd = requests.get(rootSolrUrl+'/solr/' + coreName + '/update?optimize=true&waitFlush=true&wt=json&_=' + str(int(time.time()))); | |
print('core: ' + coreName + ' optimize response: ' + rd.content); | |
else: | |
print "A valid Solr Admin URL is required"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment