changed a few things

This commit is contained in:
Jonas Winkler
2020-10-27 17:08:18 +01:00
parent 6011c82531
commit ba210d3b5e
3 changed files with 22 additions and 49 deletions

View File

@@ -8,20 +8,27 @@ from documents.models import Document
class Command(Renderable, BaseCommand):
help = "Recreates the document index"
help = "Manages the document index."
def __init__(self, *args, **kwargs):
self.verbosity = 0
BaseCommand.__init__(self, *args, **kwargs)
def add_arguments(self, parser):
parser.add_argument("command", choices=['reindex', 'optimize'])
def handle(self, *args, **options):
self.verbosity = options["verbosity"]
documents = Document.objects.all()
if options['command'] == 'reindex':
documents = Document.objects.all()
ix = index.open_index(recreate=True)
ix = index.open_index(recreate=True)
with AsyncWriter(ix) as writer:
for document in documents:
index.update_document(writer, document)
with AsyncWriter(ix) as writer:
for document in documents:
index.update_document(writer, document)
elif options['command'] == 'optimize':
index.open_index().optimize()