|
@ -112,8 +112,6 @@ class SolrClient: |
|
|
DELETE_COLLECTION = "{}/solr/admin/collections?action=DELETE&name={}&wt=json" |
|
|
DELETE_COLLECTION = "{}/solr/admin/collections?action=DELETE&name={}&wt=json" |
|
|
DELETE_DATA = "{}/solr/{}/update?commitWithin=1000&overwrite=true&wt=json" |
|
|
DELETE_DATA = "{}/solr/{}/update?commitWithin=1000&overwrite=true&wt=json" |
|
|
QUERY_DATA = "{}/solr/{}/select?q=*:*" |
|
|
QUERY_DATA = "{}/solr/{}/select?q=*:*" |
|
|
REBUILD_INDEX = "{}/solr/{}/dataimport?command=full-import&wt=json" |
|
|
|
|
|
UPDATE_INDEX = "{}/solr/{}/dataimport?command=delta-import&wt=json" |
|
|
|
|
|
|
|
|
|
|
|
CONFIGSET_NAME = "sapl_configset" |
|
|
CONFIGSET_NAME = "sapl_configset" |
|
|
|
|
|
|
|
@ -246,35 +244,6 @@ class SolrClient: |
|
|
num_docs = self.get_num_docs(collection_name) |
|
|
num_docs = self.get_num_docs(collection_name) |
|
|
print("Num docs: %s" % num_docs) |
|
|
print("Num docs: %s" % num_docs) |
|
|
|
|
|
|
|
|
def update_index_last_day(self, collection_name): |
|
|
|
|
|
date = (datetime.now() - datetime.timedelta(days=1)).strftime('%Y-%m-%dT%H:%M:%SZ') |
|
|
|
|
|
now = datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ') |
|
|
|
|
|
|
|
|
|
|
|
req_url = self.UPDATE_INDEX.format(self.url, collection_name) |
|
|
|
|
|
res = requests.post(req_url, |
|
|
|
|
|
data='<update><query>*:[%s TO %s]</query></update>' % date % now, |
|
|
|
|
|
headers={'Content-Type': 'application/xml'}) |
|
|
|
|
|
if not res.ok: |
|
|
|
|
|
print("Error updating index for collection '%s'", collection_name) |
|
|
|
|
|
print("Code {}: {}".format(res.status_code, res.text)) |
|
|
|
|
|
else: |
|
|
|
|
|
print("Collection '%s' data updated successfully!" % collection_name) |
|
|
|
|
|
|
|
|
|
|
|
num_docs = self.get_num_docs(collection_name) |
|
|
|
|
|
print("Num docs: %s" % num_docs) |
|
|
|
|
|
|
|
|
|
|
|
def rebuild_index(self, collection_name): |
|
|
|
|
|
req_url = self.REBUILD_INDEX.format(self.url, collection_name) |
|
|
|
|
|
res = requests.post(req_url) |
|
|
|
|
|
if not res.ok: |
|
|
|
|
|
print("Error rebuilding index for collection '%s'", collection_name) |
|
|
|
|
|
print("Code {}: {}".format(res.status_code, res.text)) |
|
|
|
|
|
else: |
|
|
|
|
|
print("Collection '%s' index rebuilt successfully!" % collection_name) |
|
|
|
|
|
|
|
|
|
|
|
num_docs = self.get_num_docs(collection_name) |
|
|
|
|
|
print("Num docs: %s" % num_docs) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def setup_embedded_zk(solr_url): |
|
|
def setup_embedded_zk(solr_url): |
|
|
match = re.match(URL_PATTERN, solr_url) |
|
|
match = re.match(URL_PATTERN, solr_url) |
|
@ -351,9 +320,9 @@ if __name__ == '__main__': |
|
|
|
|
|
|
|
|
if args.rebuild_index: |
|
|
if args.rebuild_index: |
|
|
print("Rebuilding index of '%s' collection..." % collection) |
|
|
print("Rebuilding index of '%s' collection..." % collection) |
|
|
client.rebuild_index(collection) |
|
|
p = subprocess.call(["python3", "manage.py", "rebuild_index", "--noinput"]) |
|
|
|
|
|
|
|
|
if args.update_index: |
|
|
if args.update_index: |
|
|
print("Updating index of '%s' collection..." % collection) |
|
|
print("Updating index of '%s' collection..." % collection) |
|
|
client.update_index_last_day(collection) |
|
|
p = subprocess.call(["python3", "manage.py", "update_index", "--noinput"]) |
|
|
|
|
|
|
|
|