From 4712bb7f6d6464933dc016c5953507c92e9bc399 Mon Sep 17 00:00:00 2001 From: Thomas Klausner Date: Tue, 7 Oct 2025 14:35:44 +0000 Subject: [PATCH] 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 --- debian/docs/koha-elasticsearch.xml | 8 +++++++- debian/scripts/koha-elasticsearch | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/debian/docs/koha-elasticsearch.xml b/debian/docs/koha-elasticsearch.xml index a4d49b9191..e180c7276b 100644 --- a/debian/docs/koha-elasticsearch.xml +++ b/debian/docs/koha-elasticsearch.xml @@ -34,7 +34,7 @@ -r|--reset -b|--biblios -a|--authorities - -v|--verbose + -w|--where -c n|--commit n -v|--verbose instancename @@ -82,6 +82,12 @@ In conjunction with it triggers bibliographic record reindexing. + + + + In conjunction with , pass some arbitrary SQL to limit the records to be indexed. + + diff --git a/debian/scripts/koha-elasticsearch b/debian/scripts/koha-elasticsearch index 851e97f49b..e9a0a1ba10 100755 --- a/debian/scripts/koha-elasticsearch +++ b/debian/scripts/koha-elasticsearch @@ -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" ;; -- 2.39.5