Bug 40890: Make batch_size configurable for koha-es-indexer

This patch adds a new configuration entry in `koha-conf.xml` for making
it possible to set a different `batch_size` for `koha-es-indexer`.

The current implementation has a default of *10* that can be overridden
using the CLI parameter `--batch_size N`.

Unfortunately, if you restart the server or the service without passing
the parameter, it will be set back to 10. This patch solves that by
adding a new config entry and making the script use it. The passed CLI
parameter will keep overridding the configured value.

To test:
1. Run:
   $ ktd --shell
  k$ koha-es-indexer --restart --batch_size 100 kohadev
  k$ ps -ef | grep elastic
=> SUCCESS: No errors. Notice '100' is passed to the called perl script
2. Run:
  k$ koha-es-indexer --restart kohadev
  k$ ps -ef | grep elastic
=> FAIL: Notice '10' is the new value
3. Apply this patch
4. Run:
  k$ reset_all
5. Repeat 1 and 2
=> SUCCESS: '100' is kept.
6. Try standalone `--start` too
7. Sign off :-D

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Tomás Cohen Arazi 2025-09-26 17:00:44 -03:00 committed by Lucas Gass
parent 33f4935bce
commit 03aec74eb6
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
4 changed files with 18 additions and 1 deletions

View File

@ -163,7 +163,7 @@ set_action()
op=""
quiet="no"
batch_size=10
batch_size=$(get_es_indexer_batch_size ${name})
# Read command line parameters
while [ $# -gt 0 ]; do

View File

@ -501,3 +501,14 @@ run_safe_xmlstarlet()
echo $(xmlstarlet sel -t -v "yazgfs/config/$myexpr" /etc/koha/sites/$instancename/koha-conf.xml)
return 0
}
get_es_indexer_batch_size()
{
local instancename=$1
local retval=$(xmlstarlet sel -t -v 'yazgfs/config/es_indexer_batch_size' /etc/koha/sites/$instancename/koha-conf.xml)
if [ "$retval" != "" ]; then
echo "$retval"
else
echo "10"
fi
}

View File

@ -372,6 +372,9 @@ __END_SRU_PUBLICSERVER__
Resetting mappings will override any changes made in the Search engine configuration UI.
-->
<!-- <elasticsearch_index_mappings>__KOHA_CONF_DIR__/searchengine/elasticsearch/mappings.yaml</elasticsearch_index_mappings> -->
<!-- How many indexing tasks the ES indexer will pick at a time
If the site is so busy the queue keeps growing, raise it -->
<es_indexer_batch_size>10</es_indexer_batch_size>
<interlibrary_loans>
<!-- Path to where Illbackends are located on the system

View File

@ -191,6 +191,9 @@
Resetting mappings will override any changes made in the Search engine configuration UI.
-->
<!-- <elasticsearch_index_mappings>__KOHA_CONF_DIR__/searchengine/elasticsearch/mappings.yaml</elasticsearch_index_mappings> -->
<!-- How many indexing tasks the ES indexer will pick at a time
If the site is so busy the queue keeps growing, raise it -->
<es_indexer_batch_size>10</es_indexer_batch_size>
<interlibrary_loans>
<!-- Path to where Illbackends are located on the system