def get(self): index = fh.get_stream_index() res = index.get_range(limit=1000) prints = "<h2>Stream index name: {}</h2>".format( fh.get_stream_index_name()) prints += "<table>" prints += "".join(['{}<br><br>'.format(r.fields) for r in res.results]) prints += "</table>" template_values = { 'simple_content': prints, 'showstreamindex_active': True } self.response.write(template.render(templatepath, template_values))
def get(self): """Delete all the docs in the given index.""" tagindex = fh.get_tag_index() streamindex = fh.get_stream_index() msg = 'Deleted all documents from indexes' for index in [tagindex, streamindex]: try: while True: # until no more documents, get a list of documents, # constraining the returned objects to contain only the doc ids, # extract the doc ids, and delete the docs. document_ids = [ document.doc_id for document in index.get_range(ids_only=True) ] if not document_ids: break index.delete(document_ids) except search.DeleteError: msg = 'Error removing exceptions' template_values = {'simple_content': msg, 'cleartagindex_active': True} self.response.write(template.render(templatepath, template_values))