Koha can currently tell how many biblios are in the database vs how many are in the elasticsearch indexes, but it cannot reconcile those differences without either bespoke work deleting individual ES documents or a full reindex. A full reindex might not solve the problem anyway, due to invalid data in MARC records. It would be really neat if the existing tool to compare-es-to-db.pl had a mode that would at least try to reconcile any discrepancies. For example if it was discovered that there were more indexes than biblios, remove the erroneous ES documents, or if there were more biblios than es indexes, identify them and attempt to reindex them. We should also provide an easy to understand error report if reconciliation was not possible, with suggested actions to take for the sysadmins or users. This would obviously be an Elasticsearch only feature.
This would be valuable for libraries--not only be able to see what the problem is but also have a first-line strategy for resolving it.
I like this idea. When we were first getting started with Elasticsearch with Koha, we were having lots of issues, so we had to write to write a script to help fix up the discrepancies. But it's difficult to do well. I think we need to start storing a timestamp in the Elasticsearch document, so that it can be compared against the biblio_metadata and items tables. If the timestamp for the bib or the item is greater than that of the ES document, then you could schedule a re-index (or maybe do a synchronous index since it's a CLI tool) for that particular record. Fortunately, we've managed to iron out the difficulties we were having, so this has been less of a pressing issue for us, but I still think it's a good idea for sure. The ES indexing can go wrong so easily, and it's currently so hard to repair without a full re-index :/.
Good idea