Skip to content
Snippets Groups Projects
Commit 8c3e00c8 authored by Erwan Rouchet's avatar Erwan Rouchet
Browse files

Add ElasticSearch reindex command

parent e6ffd93e
No related branches found
No related tags found
1 merge request!18Transcription search
#!/usr/bin/env python3
from django.core.management.base import BaseCommand
from images.models import Image
class Command(BaseCommand):
help = 'Fully reindex all transcriptions into ElasticSearch'
def handle(self, *args, **options):
nb = Image.objects.count()
last = 0
for i, img in enumerate(Image.objects.all()):
percent = int(100.0 * (i + 1) / nb)
if percent % 5 == 0 and last != percent:
print('{0: >3}% => {1: >5} / {2}'.format(percent, i, nb))
last = percent
img.index()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment