Closed megies closed 4 years ago
something like this should do it (untested):
jane/src/jane/documents/management/commands/reindex_all_documents.py
from django.core.management.base import BaseCommand
from jane.documents import models, signals
class Command(BaseCommand):
help = "Reindex all documents in Jane's document database."
def handle(self, *args, **kwargs):
for doc in models.Document.objects.all():
signals.index_document(sender=None, instance=doc, created=None)
print('.')
ofc could be extened by filters etc. - I wouldn't add anything like this to the admin backend as this probably takes ages - this would require a proper queueing setup like celery/reddis ...
Worked like a charm, thanks @barsch. Added document type filtering and pushed it to master
@barsch @krischer we are lacking an option / management command to reindex documents (especially QuakeML documents), which is quite painful when adding an index in the json field. Only workaround I have right now is download all documents, delete them and reupload, which is painful and error prone. Do you have any hints how to do it?
CC @jwassermann