def updateSolr(update_type): # real or emulated solr events if update_type == "fullIndex": index_handle = solrIndexer.delay('fullIndex','') if update_type == "timestamp": print "Updating by timestamp" index_handle = solrIndexer.delay('timestampIndex','') if update_type == "userObjects": print "Updating by userObjects" PIDs = jobs.getSelPIDs() for PID in PIDs: index_handle = solrIndexer.delay('modifyObject', PID) # purge and reindex staging solr core from fedora (SLOW) if update_type == "purgeAndFullIndex": print "Purging solr core and reindexing all objects" # delete all from /fedobjs core if 'fedobjs' in solr_handle.base_url: solr_handle.delete_by_query('*:*',commit=False) # run full index index_handle = solrIndexer.delay('fullIndex','') # purge production core, replicate from staging (FAST) if update_type == "replicateStagingToProduction": index_handle = solrIndexer.delay('replicateStagingToProduction','') # return logic if "APIcall" in request.values and request.values['APIcall'] == "True": # prepare package return_dict = { "solrIndexer":{ "update_type":update_type, "timestamp":datetime.datetime.now().isoformat(), "job_ID":index_handle.id } } # return JSON print return_dict json_string = json.dumps(return_dict) resp = make_response(json_string) resp.headers['Content-Type'] = 'application/json' return resp else: return render_template("updateSolr.html",update_type=update_type,APP_HOST=localConfig.APP_HOST)
def updateSolr(update_type): # real or emulated solr events if update_type == "fullIndex": if 'choice' not in request.form: return render_template('confirm.html',update_type=update_type) else: # fire only with confirmation if "choice" in request.form and request.form['choice'] == "confirm" and request.form['confirm_string'].lower() == 'confirm': index_handle = solrIndexer.delay('fullIndex', None) else: print 'skipping fullIndex' return redirect('/tasks/updateSolr/select') if update_type == "timestamp": print "Updating by timestamp" index_handle = solrIndexer.delay('timestampIndex', None) if update_type == "userObjects": print "Updating by userObjects" PIDs = jobs.getSelPIDs() for PID in PIDs: index_handle = solrIndexer.delay('modifyObject', PID) # purge and reindex fedobjs (SLOW) if update_type == "purgeAndFullIndex": if 'choice' not in request.form: return render_template('confirm.html',update_type=update_type) else: # fire only with confirmation if "choice" in request.form and request.form['choice'] == "confirm" and request.form['confirm_string'].lower() == 'confirm': print "Purging solr core and reindexing all objects" # delete all from /fedobjs core if 'fedobjs' in solr_handle.base_url: solr_handle.delete_by_query('*:*',commit=False) # run full index index_handle = solrIndexer.delay('fullIndex', None) else: print 'skipping purge and index' return redirect('/tasks/updateSolr/select') # return logic if "APIcall" in request.values and request.values['APIcall'] == "True": # prepare package return_dict = { "solrIndexer":{ "update_type":update_type, "timestamp":datetime.datetime.now().isoformat(), "job_ID":index_handle.id } } # return JSON print return_dict json_string = json.dumps(return_dict) resp = make_response(json_string) resp.headers['Content-Type'] = 'application/json' return resp else: return render_template("updateSolr.html",update_type=update_type,APP_HOST=localConfig.APP_HOST)