Bug 40964: add --where to koha-elasticsearch wrapper scripts and document it

Test Plan:

* Start and enter ktd
* run koha-elasticsearch with --where, which has no effect:
  debian/scripts/koha-elasticsearch --rebuild -b -v --where 'biblionumber > 427'  kohadev
* But you will see some warnings like:
  Unknown instance --where
  Unknown instance biblionumber > 427
* Final output is: Total 435 records indexed

Apply the patch

* run the same command again:
  debian/scripts/koha-elasticsearch --rebuild -b -v --where 'biblionumber > 427'  kohadev
* output should be
 Checking state of biblios index
 Indexing biblios
 Committing final records...
 Total 11 records indexed

* Run `debian/scripts/koha-elasticsearch --help`
* "-w|--where" should show up in the docs

Sponsored-by: HKS3
Sponsored-by: Koha DACH Hackfest
Signed-off-by: Anke Bruns <anke.bruns@gwdg.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Thomas Klausner 2025-10-07 14:35:44 +00:00 committed by Lucas Gass
parent dbf341bfcb
commit 41266e4e71
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 18 additions and 1 deletions

View File

@ -34,7 +34,7 @@
<arg>-r|--reset</arg>
<arg>-b|--biblios</arg>
<arg>-a|--authorities</arg>
<arg>-v|--verbose</arg>
<arg>-w|--where</arg>
<arg>-c n|--commit n</arg>
<arg>-v|--verbose</arg>
<arg choice="req" rep="repeat"><replaceable>instancename</replaceable></arg>
@ -82,6 +82,12 @@
<para>In conjunction with <option>--rebuild</option> it triggers bibliographic record reindexing.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-w</option></term>
<listitem>
<para>In conjunction with <option>--rebuild</option>, pass some arbitrary SQL to limit the records to be indexed.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-c, --commit</option></term>
<listitem>

View File

@ -46,6 +46,9 @@ Options:
they're added to Elasticsearch (default: 5000).
-p|--processes n Specify the number of parallel processes to use
for indexing.
-w|--where SQL Pass some additional SQL to limit the records to
be indexed.
--verbose|-v Be verbose.
--help|-h Print this help.
@ -114,6 +117,10 @@ run_rebuild_elasticsearch()
rebuild_opts="${rebuild_opts} -v"
fi
if [ "${where}" ]; then
rebuild_opts="${rebuild_opts} --where \"${where}\""
fi
# KOHA_HOME and KOHA_BINDIR may have been adjusted/set by adjust_paths_git_install
if koha-shell \
-c "${KOHA_HOME}/${KOHA_BINDIR}/search_tools/rebuild_elasticsearch.pl ${rebuild_opts}" \
@ -133,6 +140,7 @@ commit_size=5000
processes=1
verbose="no"
op=""
where=""
# Read parameters
while [ -n "$*" ]; do
@ -158,6 +166,9 @@ while [ -n "$*" ]; do
-p|--processes)
clo_processes="$2" ; shift
;;
-w|--where)
where="$2" ; shift
;;
--rebuild)
set_action "rebuild"
;;