Improve Elasticsearch reindexing document count verification

Description

This improves the document count verification when performing Elasticsearch reindexing operations by directly using Elasticsearch counts for comparison rather than relying on database-stored values.

Why was this needed?

The previous implementation had a potential reliability issue in the verification step. It would:

  1. Query Elasticsearch and save counts to the database
  2. Read those counts from the database to do the comparison

This approach introduced unnecessary indirection that could lead to data integrity issues if the database update failed between retrieving and comparing counts.

Related to #502817 (comment 2432750581)

Merge request reports

Loading