Bug 33019: Make sure ES records are indexed the first time
authorNick Clemens <nick@bywatersolutions.com>
Wed, 15 Feb 2023 10:50:33 +0000 (23:50 +1300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 11 Apr 2023 09:18:22 +0000 (10:18 +0100)
commitde55da7586a8206fa54917c093ad42dc6c54e82d
tree186b5dca863b9a94375be31f69fc867b6ae2c255
parent76851d9b47c953a8a50823f99f1a6a80a79f24a2
Bug 33019: Make sure ES records are indexed the first time

This patch ensures records are indexed when they are created.
Previously, we were launching the indexer inside of of a transaction.
This meant that the job was being enqueued, but not being found by the
worker, becaue it was not yet in the DB

This patch skips record indexing in the transaction, and moves the indexing
command after

To test:
1 - Make sure you are using ES, and the es indexer is running
2 - tail -f /var/log/koha/kohadev/*.log
3 - Create a new record
4 - Note error in es-indexer-output.log like:
    [2023/03/21 12:22:36] [WARN] No job found for id=157 main:: /kohadevbox/koha/misc/workers/es_indexer_daemon.pl (129)
5 - Apply patch
6 - Create another record
7  There should be no error
8 - Search for the record and confirm it can be found
9 - View the background jobs in admin, confirm the most recent job has completed

Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 48b1f230e8ea517450a02359e6f7fd530eda8b67)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
C4/Biblio.pm