Skip to content

Commit

Permalink
Improve solr reindex performance by using a tuple instead a set for idxs
Browse files Browse the repository at this point in the history
  • Loading branch information
elioschmutz committed Apr 8, 2024
1 parent b8e2420 commit 8b272b0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions opengever/maintenance/scripts/repository_migration.py
Expand Up @@ -1369,7 +1369,7 @@ def rename(self, items):
# We do not need to reindex path as this seems to already happen
# recursively
self.add_to_reindexing_queue(
item['uid'], ('Title', 'sortable_title'))
item['uid'], ('Title', 'title_de', 'title_fr', 'title_en', 'sortable_title'))
if not self.dry_run:
transaction.commit()

Expand Down Expand Up @@ -1433,7 +1433,10 @@ def reindex(self):
if not obj:
logger.error("Could not find {} to reindex. Skipping".format(uid))
continue
obj.reindexObject(idxs=idxs)

# WARNING! idxs needs to be a tuple, otherwise solr will always update all attributes
# See: https://github.com/plone/collective.indexing/blob/2.0/src/collective/indexing/queue.py#L142
obj.reindexObject(idxs=tuple(idxs))
if obj.portal_type == 'opengever.task.task':
# make sure that the model is up to date.
TaskSqlSyncer(obj, None).sync()
Expand Down

0 comments on commit 8b272b0

Please sign in to comment.