Skip to content
This repository was archived by the owner on Apr 11, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions django_elasticsearch_dsl/management/commands/search_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,21 @@ def _populate(self, models, options):
celery_task = import_string(getattr(settings,'ELASTICSEARCH_DSL_CELERY_TASK'))
celery_queue = getattr(settings, 'ELASTICSEARCH_DSL_CELERY_QUEUE')
for doc in registry.get_documents(models):
min_chunk_id = 0
if options['docs_start']:
min_chunk_id = options['docs_start']
max_chunk_id = int(ceil(doc().get_max_id() / doc().django.queryset_pagination))
if options['docs_end']:
max_chunk_id = options['docs_end']
self.stdout.write(
"Indexing {} '{}' objects {}, processing in {} chunks".format(
doc().get_queryset().count() if options['count'] else "all",
doc.django.model.__name__,
"(parallel)" if parallel else "",
max_chunk_id
max_chunk_id - min_chunk_id
)
)
for chunk_id in range(0, max_chunk_id):
for chunk_id in range(min_chunk_id, max_chunk_id):
celery_task.apply_async(
kwargs={
"document": "{path}.{name}".format(
Expand Down