Bug 40964

Summary: koha-elasticsearch is missing --where option
Product: Koha Reporter: Thomas Klausner <domm>
Component: Command-line UtilitiesAssignee: Bugs List <koha-bugs>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: anke.bruns, robin
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: Sponsored
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 40964: add --where to koha-elasticsearch wrapper scripts and document it
Bug 40964: add --where to koha-elasticsearch wrapper scripts and document it

Description Thomas Klausner 2025-10-07 13:55:09 UTC
misc/search_tools/rebuild_elasticsearch.pl has an option --where to pass arbitrary SQL to select which records to index.

The koha-elasticsearch wrapper script is missing this option.

Add it!
Comment 1 Thomas Klausner 2025-10-07 14:47:02 UTC
Created attachment 187530 [details] [review]
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
Comment 2 Anke Bruns 2025-10-08 11:05:02 UTC
Created attachment 187555 [details] [review]
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: John Doe <you@example.com>
Signed-off-by: Anke Bruns <anke.bruns@gwdg.de>