Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#957 | ES batch indexes | extract doc
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Dec 30, 2023
1 parent 499c4c7 commit b17acc0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,12 @@ def get_exact_or_criteria(attr, values):
@staticmethod
def batch_index(queryset, document, single_batch=False):
if not get(settings, 'TEST_MODE'):
doc = document()
if single_batch or not get(settings, 'DB_CURSOR_ON', True):
document().update(queryset.all(), parallel=True)
doc.update(queryset.all(), parallel=True)
else:
for batch in queryset.iterator(chunk_size=500):
document().update(batch, parallel=True)
doc.update(batch, parallel=True)

@staticmethod
@transaction.atomic
Expand Down

0 comments on commit b17acc0

Please sign in to comment.