arruma o processo de busca textual nos diarios
This commit is contained in:
24
diarios/management/commands/reindex_diarios.py
Normal file
24
diarios/management/commands/reindex_diarios.py
Normal file
@ -0,0 +1,24 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from django_elasticsearch_dsl.registries import registry
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Reindexar todos os Diários Oficiais no Elasticsearch'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
self.stdout.write('Iniciando reindexação...')
|
||||
|
||||
# Recria os índices
|
||||
registry.delete_indices()
|
||||
registry.create_indices()
|
||||
|
||||
# Reindexar documentos
|
||||
for index in registry.get_indices():
|
||||
self.stdout.write(f'Reindexando {index}...')
|
||||
documents = []
|
||||
for doc in registry.get_documents():
|
||||
if index == doc._index._name:
|
||||
self.stdout.write(f' + {doc.__name__}')
|
||||
doc().update()
|
||||
|
||||
self.stdout.write(self.style.SUCCESS('Reindexação concluída!'))
|
||||
|
||||
Reference in New Issue
Block a user