Koha Solutions knowledge base: run log of a live check Article https://kohasolutions.com/knowledge-base/koha-search-no-results Check scripts/kb/live/koha-search-no-results.mjs (SHA-256 7500f6188b695cca4b89dc0eeb548618966550c996b7d12b9570c08f89fbf13a) Ran 2026-11-06T17:08:03Z (UTC), 580 s Koha 26.05.02 (Koha::version 26.05.02.002, database version 26.0600002) Source https://git.koha-community.org/Koha-community/Koha/src/commit/d3fc229bc5eaea25dfe88f86149386408fe5d32d System Debian GNU/Linux 13 (trixie) Result PASS: all 42 claims held Each claim is something the article says. "seen" is what the check read back when it is not just a yes/no. Changes the check made to the test server were undone afterwards, as its header describes. == Claims == ok the SearchEngine query prints "value" then "Zebra" seen: value Zebra ok healthy baseline: OPAC search for "history" returns results seen: Your search returned 60 results ok koha-zebra --status → "Zebra running for :." ok koha-zebra --stop without -v prints nothing seen: {"out":"","err":"","code":0} ok stopped: "Zebra not running for : failed!" (exit 3) seen: 3 Zebra not running for kohadev: failed! ok Zebra stopped → OPAC "No results found!" seen: No results found! ok …the page says "No results found for that in catalog." (no error shown) seen: No results found! | No results found for that in catalog. | Not finding wha ok …the staff interface also finds nothing ("No results match your search") seen: Search for 'kw,wrdl: "history"' | Help | Search results | Z39.50/SRU search | No results found | No results match your search for 'kw,wrdl: "history"'. | Edit this search ok …but a record opens by its number (opac-detail.pl?biblionumber=17) ok …and no log says why: zebra-error.log unchanged, no Zebra/ZOOM line in plack-opac-error.log seen: [2026/11/06 17:08:25] [WARN] CGI::param called in list context from /kohadevbox/koha/opac/opac-search.pl line 641, this can lead to vulnerabilities. See the warning in "Fetching the value or values of a single named parameter" at /usr/share/perl5/CGI.pm line 416. [2026/11/06 17:08:25] [WARN] Odd num ok koha-zebra -v --start → "Starting Koha Zebra daemon for :." seen: Starting Koha Zebra daemon for kohadev:. ok Zebra started → search returns results again, no rebuild needed seen: Your search returned 60 results ok koha-zebra -v --stop → "Stopping Koha Zebra daemon for :." seen: Stopping Koha Zebra daemon for kohadev:. ok …with connections open, --status still says "Zebra running for :." seen: Zebra running for kohadev:. / 1 daemon --name=kohadev-koha-zebra ; 442411 [zebrasrv] ; 1 kohadev-koha-zebra: /usr/bin/zeb ; 1 kohadev-koha-zebra: /usr/bin/zeb ok …while every search says "No results found!" seen: No results found! ok …-v --start answers "Error: Zebra already running for : failed!" (or starts, once the leftovers are gone) seen: Starting Koha Zebra daemon for kohadev:. ok koha-plack --restart → "Stopping Plack daemon for :." / "Starting Plack daemon for :." seen: Stopping Plack daemon for kohadev:. Starting Plack daemon for kohadev:. ok …and -v --start brings search back seen: Your search returned 60 results ok koha-zebra -v --restart with connections open → "Stopping…:." then "Starting…:." or "Error: Zebra already running for : failed!" (the latter leaves search empty) seen: Stopping Koha Zebra daemon for kohadev:. Error: Zebra already running for kohadev: failed! | No results found! ok …fixed the same way: koha-plack --restart, then koha-zebra -v --start seen: Your search returned 60 results ok index emptied (zebraidx init): Zebra and the indexer still report running ok …and every search says "No results found!" seen: No results found! ok koha-rebuild-zebra -f -v -b: "Records exported: N" within a handful of COUNT(*), "Indexing complete:" seen: exported 1095, biblio 1100 Zebra configuration information ================================ Zebra biblio directory = /var/lib/koha/kohadev/biblios Zebra authorities directory = /var/lib/koha/kohadev/authorities Koha directory = /kohadevbox/koha Lockfile = /var/lock/koha/kohadev/rebuild/rebuild..LCK BIBLIONUMBER in : 999$c BIBLIOITEMNUMBER in : 999$d ================================ Job started: 17:09:47 skipping authorities ==================== exporting biblio 17:09:47 [00:00:00] ==================== . 1.................................................................................................... 101.................................................................................................... 201.................................................................................................... 301...................................................................:8: parser error : PCDATA invalid Char value 31 00aD000015937 ^ :9: parser error : PCDATA invalid Char value 31 00satmrnu0 ^ :9: parser error : PCDATA invalid Char value 31 00satmrnu0 ^ :9: parser error : PCDATA invalid Char value 31 00satmrnu0 ^ :9: parser error : PCDATA invalid Char value 31 00satmrnu0 ^ :10: parser error : PCDATA invalid Char value 31 00ar19881981bdkldan ^ :10: parser error : PCDATA invalid Char value 31 00ar19881981bdkldan ^ :10: parser error : PCDATA invalid Char value 31 00ar19881981bdkldan ^ at /kohadevbox/koha/Koha/Biblio/Metadata.pm line 117. error retrieving biblio 369 at /kohadevbox/koha/misc/migration_tools/rebuild_zebra.pl line 789. ................................. 401.................................................................................................... 501.................................................................................................... 601.................................................................................................... 701.................................................................................................... 801.................................................................................................... 901.................................................................................................... 1001............................................................................................... Records exported: 1095 17:09:57 [00:00:10] ==================== REINDEXING zebra 17:09:57 [00:00:10] ==================== ==================== Indexing complete: 17:10:00 [00:00:13] ==================== CLEANING ==================== ok after the rebuild, search returns results, at the latest after koha-plack --restart [right after rebuild: Your search returned 60 results] seen: Your search returned 60 results ok koha-mysql COUNT(*) prints "COUNT(*)" then the number seen: COUNT(*) 1100 ok nothing on localhost:9200 → curl: (7) Failed to connect to localhost port 9200 … Could not connect to server seen: curl: (7) Failed to connect to localhost port 9200 after 0 ms: Could not connect to server ok grep -A3 "" shows the line seen: localhost:9200 koha_kohadev ok SearchEngine Elasticsearch, server down → OPAC "No results found!" seen: No results found! ok …plack-opac-error.log: "[NoNodes] ** No nodes are available: [http://localhost:9200]" seen: [2026/11/06 17:10:27] [WARN] [NoNodes] ** No nodes are available: [http://localhost:9200], called from sub Search::Elasticsearch::Role::Client::Direct::__ANON__ at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch/Search.pm line 101. ok grep NoNodes … | tail -1 prints that line seen: [2026/11/06 17:10:27] [WARN] [NoNodes] ** No nodes are available: [http://localhost:9200], called from sub Search::Elasticsearch::Role::Client::Direct::__ANON__ at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch/Search.pm line 101. ok koha-es-indexer --status (not started) → "ES indexing daemon not running for : failed!" seen: ES indexing daemon not running for kohadev: failed! ok test Elasticsearch 8.17 answers ok _cluster/health?pretty → "status" : "green" seen: { "cluster_name" : "docker-cluster", "status" : "green", "timed_out" : false, "number_of_nodes" : 1, "number_of_data_nodes" : 1, "active_primary_shards" : 0, "active_shards" : 0, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0, "unassigned_primary_shards" : 0, "delayed_unassigned_shards" : 0, "number_of_pending_tasks" : 73, "number_of_in_flight_fetch" : 0, "task_max_waiting_in_queue_millis" : 3612, "active_shards_percent_as_number" : 100.0 } ok Elasticsearch up, indexes never built → OPAC "No results found!" seen: No results found! ok …plack-opac-error.log: index_not_found_exception / "no such index [koha__biblios]" seen: [2026/11/06 17:11:14] [WARN] [Missing] ** [http://kbverify-es:9200]-[404] [index_not_found_exception] no such index [koha_kohadev_biblios], with: {"resource.type":"index_or_alias","index":"koha_kohadev_biblios","resource.id":"koha_kohadev_biblios","index_uuid":"_na_"}, called from sub Search::Elasticsearch::Role::Cxn::process_response at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch.pm line 56. With vars: {'status_code' => 404,'request' => {'serialize' => 'std','body' => {'aggregations' => {'author' => {'terms' => {'field' => 'author__facet','size' => '20'}},'location' => {'terms' => {'field' => 'location__facet','size' => '20'}},'ln' => {'terms' => {'size' => '20','field' => 'ln__facet'}},'su-geo' => {'terms' => {'size' => '20','field' => 'su-geo__facet'}},'homebranch' => {'terms' => {'field' => 'homebranch__facet','size' => '20'}},'title-series' => {'terms' => {'size' => '20','field' => 'title-series__facet'}},'subject' => {'terms' => {'size' => '20','field' => 'subject__facet'}},'itype' => {'terms' => {'size' => '20','field' => 'itype__facet'}},'holdingbranch' => {'terms' => {'size' => '20','field' => 'holdingbranch__facet'}},'ccode' => {'terms' => {'size' => '20','field' => 'ccode__facet'}}},'size' => '20','query' => {'bool' => {'must' => [{'query_string' => {'fields' => ['number-legal-deposit','material-type','ccode','map-scale','author-name-corporate','other-control-number','interest-grade-level','geolocation_lon','author-in-order','arp','bnb-card-number','publisher','llength','uri','local-number','ff7-02','author-name-personal','ln-subtitle','dewey-classification','replacementprice','cn-suffix','arl','lc-call-number','number-db','music-key','title','title-other-variant','coded-location-qualifier','title-collective','ff8-29','title-no-punctuation','cn-prefix','lost','title-former','withdrawn','materials-specified','editor','identifier-standard','datelastborrowed','subject','itemnumber','issues','copynumber','title-key','host-item','totalissues','ctype','index-term-genre','name-and-title','provider','note','ff7-00','cn-bib-source','title-later','cn-sort','bio','nlm-call-number','holdingbranch','extent','host-item-number','name-geographic','ta','identifier-other','record-source','issn-all','report-number','number-local-acquisition','date-of-publication','cn-item','code-geographic','date-entered-on-file','author-title','isbn-all','ln','language-original','datelastseen','itype','stack','musical-presentation','lf','bgf-number','ff7-01-02','notforloan','title-abbreviated','bib-level','replacementpricedate','copydate','reserves','thematic-number','rtype','related-periodical','abstract','damaged','geographic-class','nal-call-number','title-expanded','udc-classification','curriculum','lexile-number','corporate-name','ff7-01','title-uniform','cn-bib-sort','title-cover','geolocation_lat','cn-class','microform-generation','author-personal-bibliography','location','fingerprint-identifier','date-time-last-modified','classification-source','local-classification','not-onloan-count','name','number-govt-pub','reading-grade-level','author','lc-card-number','koha-auth-number','indexed-by','price','index-term-uncontrolled','ff8-23','barcode','su-geo','control-number','number-natl-biblio','coden','homebranch','personal-name','title-series','restricted','record-control-number','conference-name','issn','acqsource','pl','ln-audio','dissertation-information','identifier-publisher-for-music','stock-number','isbn','biblioitemnumber','control-number-identifier','date-of-acquisition','renewals','code-institution','interest-age-level','current-publication-frequency','itemtype','cross-reference','subject-name-personal'],'fuzziness' => 'auto','type' => 'cross_fields','lenient' => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' ),'analyze_wildcard' => $VAR1->{'request'}{'body'}{'query'}{'bool'}{'must'}[0]{'query_string'}{'lenient'},'default_operator' => 'AND','query' => '(history*)'}}]}},'sort' => [{'_score' => {'order' => 'desc'}},{'local-number__sort' ok grep index_not_found … | tail -1 → "[WARN] [Missing] ** [http://]-[404] [index_not_found_exception] no such index [koha__biblios], …" seen: [2026/11/06 17:11:14] [WARN] [Missing] ** [http://kbverify-es:9200]-[404] [index_not_found_exception] no such index [koha_kohadev_biblios], with: {"resource.type":"index_or_alias","index":"koha_kohadev_biblios","resource.id":"koha_kohadev_biblios","index_uuid":"_na_"}, called from sub Search::Elasticsearch::Role::Cxn::process_response at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch.pm line 56. With vars: {'status_code' => 404,'request' => {'serialize' => 'std','body' => {'aggregations' => {'author' => {'terms' => {'field' => 'author__facet','size' => '20'}},'location' => {'terms' => {'field' => 'location__facet','size' => '20'}},'ln' => {'terms' => {'size' => '20','field' => 'ln__facet'}},'su-geo' => {'terms' => {'size' => '20','field' => 'su-geo__facet'}},'homebranch' => {'terms' => {'field' => 'homebranch__facet','size' => '20'}},'title-series' => {'terms' => {'size' => '20','field' => 'title-series__facet'}},'subject' => {'terms' => {'size' => '20','field' => 'subject__facet'}},'itype' => {'terms' => {'size' => '20','field' => 'itype__facet'}},'holdingbranch' => {'terms' => {'size' => '20','field' => 'holdingbranch__facet'}},'ccode' => {'terms' => {'size' => '20','field' => 'ccode__facet'}}},'size' => '20','query' => {'bool' => {'must' => [{'query_string' => {'fields' => ['number-legal-deposit','material-type','ccode','map-scale','author-name-corporate','other-control-number','interest-grade-level','geolocation_lon','author-in-order','arp','bnb-card-number','publisher','llength','uri','local-number','ff7-02','author-name-personal','ln-subtitle','dewey-classification','replacementprice','cn-suffix','arl','lc-call-number','number-db','music-key','title','title-other-variant','coded-location-qualifier','title-collective','ff8-29','title-no-punctuation','cn-prefix','lost','title-former','withdrawn','materials-specified','editor','identifier-standard','datelastborrowed','subject','itemnumber','issues','copynumber','title-key','host-item','totalissues','ctype','index-term-genre','name-and-title','provider','note','ff7-00','cn-bib-source','title-later','cn-sort','bio','nlm-call-number','holdingbranch','extent','host-item-number','name-geographic','ta','identifier-other','record-source','issn-all','report-number','number-local-acquisition','date-of-publication','cn-item','code-geographic','date-entered-on-file','author-title','isbn-all','ln','language-original','datelastseen','itype','stack','musical-presentation','lf','bgf-number','ff7-01-02','notforloan','title-abbreviated','bib-level','replacementpricedate','copydate','reserves','thematic-number','rtype','related-periodical','abstract','damaged','geographic-class','nal-call-number','title-expanded','udc-classification','curriculum','lexile-number','corporate-name','ff7-01','title-uniform','cn-bib-sort','title-cover','geolocation_lat','cn-class','microform-generation','author-personal-bibliography','location','fingerprint-identifier','date-time-last-modified','classification-source','local-classification','not-onloan-count','name','number-govt-pub','reading-grade-level','author','lc-card-number','koha-auth-number','indexed-by','price','index-term-uncontrolled','ff8-23','barcode','su-geo','control-number','number-natl-biblio','coden','homebranch','personal-name','title-series','restricted','record-control-number','conference-name','issn','acqsource','pl','ln-audio','dissertation-information','identifier-publisher-for-music','stock-number','isbn','biblioitemnumber','control-number-identifier','date-of-acquisition','renewals','code-institution','interest-age-level','current-publication-frequency','itemtype','cross-reference','subject-name-personal'],'fuzziness' => 'auto','type' => 'cross_fields','lenient' => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' ),'analyze_wildcard' => $VAR1->{'request'}{'body'}{'query'}{'bool'}{'must'}[0]{'query_string'}{'lenient'},'default_operator' => 'AND','query' => '(history*)'}}]}},'sort' => [{'_score' => {'order' => 'desc'}},{'local-number__sort' ok _cat/indices?v lists only the header (no koha_ index) seen: health status index uuid pri rep docs.count docs.deleted store.size pri.store.size dataset.size ok analysis-icu installed for the rebuild seen: -> Installing analysis-icu -> Downloading analysis-icu from elastic -> Installed analysis-icu -> Please restart Elasticsearch to activate any plugins installed ok koha-elasticsearch --rebuild -d -v → "Total N records indexed" for biblios and authorities seen: 1095, 1720 (biblio 1100) [444153] Checking state of biblios index [444153] Dropping and recreating biblios index [444153] Checking state of authorities index [444153] Dropping and recreating authorities index [444153] Indexing biblios :8: parser error : PCDATA invalid Char value 31 00aD000015937 ^ :9: parser error : PCDATA invalid Char value 31 00satmrnu0 ^ :9: parser error : PCDATA invalid Char value 31 00satmrnu0 ^ :9: parser error : PCDATA invalid Char value 31 00satmrnu0 ^ :9: parser error : PCDATA invalid Char value 31 00satmrnu0 ^ :10: parser error : PCDATA invalid Char value 31 00ar19881981bdkldan ^ :10: parser error : PCDATA invalid Char value 31 00ar19881981bdkldan ^ :10: parser error : PCDATA invalid Char value 31 00ar19881981bdkldan ^ at /kohadevbox/koha/Koha/Biblio/Metadata.pm line 117. Something went wrong reading record for biblio 369: Invalid data, cannot decode metadata object (biblio_metadata.id=368, biblionumber=369, format=marcxml, schema=MARC21, decoding_error=':8: parser error : PCDATA invalid Char value 31 00aD000015937 ^ :9: parser error : PCDATA invalid Char value 31 00satmrnu0 ^ :9: parser error : PCDATA invalid Char value 31 00satmrnu0 ^ :9: parser error : PCDATA invalid Char value 31 00satmrnu0 ^ :9: parser error : PCDATA invalid Char value 31 00satmrnu0 ^ :10: parser error : PCDATA invalid Char value 31 00ar19881981bdkldan ^ :10: parser error : PCDATA invalid Char value 31 00ar19881981bdkldan ^ :10: parser error : PCDATA invalid Char value 31 00ar19881981bdkldan ^') [444153] 1000 records processed Something went wrong reading record for biblio 3657: DBIC result _type isn't of the _type BiblioMetadata at /kohadevbox/koha/Koha/BiblioUtils.pm line 155. Something went wrong reading record for biblio 3658: DBIC result _type isn't of the _type BiblioMetadata at /kohadevbox/koha/Koha/BiblioUtils.pm line 155. Something went wrong reading record for biblio 3729: DBIC result _type isn't of the _type BiblioMetadata at /kohadevbox/koha/Koha/BiblioUtils.pm line 155. Something went wrong reading record for biblio 3728: DBIC result _type isn't of the _type BiblioMetadata at /kohadevbox/koha/Koha/BiblioUtils.pm line 155. [444153] Committing final records... [444153] Total 1095 records indexed [444153] Indexing authorities [444153] 1000 records processed [444153] Committing final records... Cannot determine authority type for record: 1 at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch.pm line 686. [444153] Total 1720 records indexed ok _cat/indices?v now lists koha_kohadev_biblios and koha_kohadev_authorities seen: health status index uuid pri rep docs.count docs.deleted store.size pri.store.size dataset.size yellow open koha_kohadev_biblios qxAOeKvSQd6aZ54Ra-6bcA 5 1 1095 0 15.7mb 15.7mb 15.7mb yellow open koha_kohadev_authorities ZDlmlek_Q32V_ipy1fvVwQ 5 1 1049 0 2.3mb 2.3mb 2.3mb ok on one server, health after the build is "yellow" (replicas cannot be placed) seen: { "cluster_name" : "docker-cluster", "status" : "yellow", "timed_out" : false, ok after the build, search returns results (no Plack restart needed) seen: Your search returned 60 results == The check that produced this log (scripts/kb/live/koha-search-no-results.mjs) == /** * Live check for prisma/ks-kb/111-koha-search-no-results.ts: every search says "No results found" while the records * are there. Breaks search each way the article covers and fixes it the way the article says, on live Koha (~4 min, * needs internet once for the Elasticsearch ICU plugin). * * Changes, all undone: Zebra stopped and started (left running); the Zebra biblio index emptied with zebraidx init * and rebuilt; `koha-zebra --restart` shown to leave Zebra stopped (started again); a throwaway Elasticsearch 8.17 * container `kbverify-es` on the Koha network (removed); in koha-conf.xml pointed first at localhost:9200 * (nothing listens) then at kbverify-es (file restored, Plack restarted); SearchEngine (setPref). */ import { spawnSync } from 'node:child_process' export const meta = { koha: '26.05.02', passed: '2026-11-06' } const ES_IMAGE = 'docker.elastic.co/elasticsearch/elasticsearch:8.17.0' const docker = (...args) => spawnSync('docker', args, { encoding: 'utf8', timeout: 600000 }) const sleep = (ms) => new Promise((r) => setTimeout(r, ms)) export default async function run(ctx) { const I = ctx.INSTANCE const conf = `/etc/koha/sites/${I}/koha-conf.xml` const opacLog = `/var/log/koha/${I}/plack-opac-error.log` const zlog = `/var/log/koha/${I}/zebra-error.log` const search = (q) => ctx.sh(`curl -s -o /tmp/kbv-s.html "http://localhost:8080/cgi-bin/koha/opac-search.pl?q=${q}"; grep -o -E "No results found!|Your search returned [0-9]+ results" /tmp/kbv-s.html | head -1; rm -f /tmp/kbv-s.html`).out const results = (q) => /Your search returned [1-9]/.test(search(q)) const zebraUp = () => ctx.sh(`koha-zebra --status ${I}`).code === 0 const untilZebra = async (want) => { for (let i = 0; i < 40; i++) { if (zebraUp() === want) return true; await sleep(500) } return false } const plackRestart = async () => { ctx.sh(`koha-plack --restart ${I} >/dev/null 2>&1`); for (let i = 0; i < 30; i++) { await sleep(2000); if (ctx.sh('curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/cgi-bin/koha/opac-main.pl').out === '200') return } } const logFrom = (file) => { const n = Number(ctx.sh(`wc -l < ${file}`).out); return () => ctx.sh(`tail -n +${n + 1} ${file}`).out } const staffSearch = async (page) => { await page.goto(`${ctx.STAFF}/cgi-bin/koha/catalogue/search.pl?q=history`); return ctx.pageText(page) } // Undo, in reverse order of registration: Zebra running and its index rebuilt if needed, container, Plack, conf, pref. ctx.restore('remove the test Elasticsearch', () => docker('rm', '-f', 'kbverify-es')) ctx.restore('restart Plack on the restored config', () => { ctx.sh(`koha-plack --restart ${I} >/dev/null 2>&1`) }) ctx.backupFile(conf) ctx.restore('Zebra running with a full biblio index', async () => { if (!zebraUp()) { ctx.sh(`koha-zebra --start ${I}`); await untilZebra(true) } if (!results('history')) { ctx.sh(`koha-rebuild-zebra -f -b ${I} >/dev/null 2>&1`); ctx.sh(`koha-zebra --stop ${I}`); await untilZebra(false); ctx.sh(`koha-zebra --start ${I}`); await untilZebra(true) } }) // --- Step 1: which engine, and is it the index at all ------------------------------------------------------------- const engine = ctx.sh(`koha-mysql ${I} -e "SELECT value FROM systempreferences WHERE variable='SearchEngine';"`).out ctx.check('the SearchEngine query prints "value" then "Zebra"', engine === 'value\nZebra', engine) ctx.check('healthy baseline: OPAC search for "history" returns results', results('history'), search('history')) ctx.check('koha-zebra --status → "Zebra running for :."', ctx.sh(`koha-zebra --status ${I}`).out === `Zebra running for ${I}:.`) const plackR = async () => { const o = ctx.sh(`koha-plack --restart ${I} 2>&1`).out; await plackRestart(); return o } // --- A. Zebra not running (as after a reboot that did not start it) ------------------------------------------------ // Plack restarted first so no worker holds a Zebra connection: then a stop really stops (B shows the other case). await plackR() const zSize = ctx.sh(`stat -c %s ${zlog}`).out const opacNew = logFrom(opacLog) const stop = ctx.sh(`koha-zebra --stop ${I}`) ctx.check('koha-zebra --stop without -v prints nothing', stop.out === '' && stop.err === '' && stop.code === 0, JSON.stringify(stop)) await untilZebra(false) const st = ctx.sh(`koha-zebra --status ${I}`) ctx.check('stopped: "Zebra not running for : failed!" (exit 3)', st.out === `Zebra not running for ${I}: failed!` && st.code === 3, `${st.code} ${st.out}`) ctx.check('Zebra stopped → OPAC "No results found!"', search('history') === 'No results found!', search('history')) const opac = await ctx.newPage() await opac.goto(`${ctx.OPAC}/cgi-bin/koha/opac-search.pl?q=history`) const opacText = await ctx.pageText(opac) ctx.check('…the page says "No results found for that in catalog." (no error shown)', /No results found for that in\s+catalog\./.test(opacText) && !/error/i.test(opacText.replace(/errors?\/404/g, '')), (opacText.match(/No results found.{0,60}/) ?? [''])[0]) const staff = await ctx.newPage() await ctx.staffLogin(staff) const staffText = await staffSearch(staff) ctx.check('…the staff interface also finds nothing ("No results match your search")', /No results match your search/.test(staffText), (staffText.match(/.{0,80}No results.{0,120}/) ?? [staffText.slice(0, 200)])[0]) await opac.goto(`${ctx.OPAC}/cgi-bin/koha/opac-detail.pl?biblionumber=17`) ctx.check('…but a record opens by its number (opac-detail.pl?biblionumber=17)', (await ctx.pageText(opac)).includes('Damned to fame')) ctx.check('…and no log says why: zebra-error.log unchanged, no Zebra/ZOOM line in plack-opac-error.log', ctx.sh(`stat -c %s ${zlog}`).out === zSize && !/zebra|zoom|connect/i.test(opacNew()), opacNew().slice(0, 300)) const start = ctx.sh(`koha-zebra -v --start ${I}`) ctx.check('koha-zebra -v --start → "Starting Koha Zebra daemon for :."', start.out === `Starting Koha Zebra daemon for ${I}:.`, start.out + start.err) await untilZebra(true) await sleep(1000) ctx.check('Zebra started → search returns results again, no rebuild needed', results('history'), search('history')) // --- B. Stopped while Plack holds connections: status still says running ------------------------------------------- for (let i = 0; i < 3; i++) search('history') const vstop = ctx.sh(`koha-zebra -v --stop ${I}`).out ctx.check('koha-zebra -v --stop → "Stopping Koha Zebra daemon for :."', vstop === `Stopping Koha Zebra daemon for ${I}:.`, vstop) await sleep(5000) const half = ctx.sh(`koha-zebra --status ${I}`).out ctx.check('…with connections open, --status still says "Zebra running for :."', half === `Zebra running for ${I}:.`, half + ' / ' + ctx.sh('ps -eo ppid,args | grep "[z]ebrasrv" | cut -c1-40').out.replace(/\n/g, ' ; ')) ctx.check('…while every search says "No results found!"', search('history') === 'No results found!', search('history')) // How long the leftover processes live depends on when Plack's connections close, so --start may refuse or work. const refused = ctx.sh(`koha-zebra -v --start ${I}`).out ctx.check('…-v --start answers "Error: Zebra already running for : failed!" (or starts, once the leftovers are gone)', [`Error: Zebra already running for ${I}: failed!`, `Starting Koha Zebra daemon for ${I}:.`].includes(refused), refused) const pr = await plackR() ctx.check('koha-plack --restart → "Stopping Plack daemon for :." / "Starting Plack daemon for :."', pr === `Stopping Plack daemon for ${I}:.\nStarting Plack daemon for ${I}:.`, pr) await sleep(2000) const after = ctx.sh(`koha-zebra --status ${I}`).out if (after !== `Zebra running for ${I}:.`) ctx.check('…after it, a refused start shows as "Zebra not running for : failed!"', after === `Zebra not running for ${I}: failed!`, after) if (!zebraUp()) ctx.sh(`koha-zebra -v --start ${I}`) await untilZebra(true) await sleep(1000) ctx.check('…and -v --start brings search back', results('history'), search('history')) // --- C. --restart with connections open: the same trap ------------------------------------------------------------- for (let i = 0; i < 3; i++) search('history') const rs = ctx.sh(`koha-zebra -v --restart ${I}`).out await sleep(4000) const afterRs = search('history') ctx.check(`koha-zebra -v --restart with connections open → "Stopping…:." then "Starting…:." or "Error: Zebra already running for : failed!" (the latter leaves search empty)`, rs === `Stopping Koha Zebra daemon for ${I}:.\nStarting Koha Zebra daemon for ${I}:.` || (rs === `Stopping Koha Zebra daemon for ${I}:.\nError: Zebra already running for ${I}: failed!` && afterRs === 'No results found!'), `${rs} | ${afterRs}`) await plackR(); await sleep(2000); if (!zebraUp()) ctx.sh(`koha-zebra --start ${I}`); await untilZebra(true); await sleep(1000) ctx.check('…fixed the same way: koha-plack --restart, then koha-zebra -v --start', results('history'), search('history')) // --- D. An emptied index ---------------------------------------------------------------------------------------------- const cfg = `/etc/koha/sites/${I}/zebra-biblios-dom.cfg` ctx.sh(`koha-shell ${I} -c 'zebraidx -c ${cfg} -v none,fatal,warn -g marcxml -d biblios init; zebraidx -c ${cfg} -v none,fatal,warn -g marcxml -d biblios commit'`) ctx.check('index emptied (zebraidx init): Zebra and the indexer still report running', zebraUp() && ctx.sh(`koha-indexer --status ${I}`).out === `Indexer running for ${I}:.`) ctx.check('…and every search says "No results found!"', search('history') === 'No results found!', search('history')) const rb = ctx.sh(`koha-rebuild-zebra -f -v -b ${I} 2>&1`).out const exported = Number(rb.match(/Records exported: (\d+)/)?.[1] ?? NaN) const biblios = Number(ctx.sqlValue('SELECT COUNT(*) FROM biblio')) ctx.check('koha-rebuild-zebra -f -v -b: "Records exported: N" within a handful of COUNT(*), "Indexing complete:"', rb.includes('Indexing complete:') && Math.abs(exported - biblios) <= 5, `exported ${exported}, biblio ${biblios}\n${rb}`) await sleep(3000) const afterRb = search('history') // Depends on whether a Plack worker still talks to a Zebra process opened before the index was emptied. await plackR(); await sleep(2000); if (!zebraUp()) ctx.sh(`koha-zebra --start ${I}`); await untilZebra(true); await sleep(1000) ctx.check(`after the rebuild, search returns results, at the latest after koha-plack --restart [right after rebuild: ${afterRb}]`, results('history'), search('history')) const count = ctx.sh(`koha-mysql ${I} -e "SELECT COUNT(*) FROM biblio;"`).out ctx.check('koha-mysql COUNT(*) prints "COUNT(*)" then the number', count === `COUNT(*)\n${biblios}`, count) // --- Elasticsearch: server not reachable --------------------------------------------------------------------------- const health0 = ctx.sh("curl -sS 'http://localhost:9200/_cluster/health?pretty'") ctx.check('nothing on localhost:9200 → curl: (7) Failed to connect to localhost port 9200 … Could not connect to server', health0.code === 7 && /^curl: \(7\) Failed to connect to localhost port 9200 after \d+ ms: Could not connect to server$/.test(health0.err), health0.err) ctx.sh(`sed -i -E 's#[^<]*#localhost:9200#' ${conf}`) const grepConf = ctx.sh(`grep -A3 '' ${conf}`).out ctx.check('grep -A3 "" shows the line', grepConf.includes('localhost:9200') && grepConf.includes('koha_'), grepConf) ctx.setPref('SearchEngine', 'Elasticsearch') await plackRestart() const opacNew2 = logFrom(opacLog) const esDown = search('history') ctx.check('SearchEngine Elasticsearch, server down → OPAC "No results found!"', esDown === 'No results found!', esDown) ctx.check('…plack-opac-error.log: "[NoNodes] ** No nodes are available: [http://localhost:9200]"', opacNew2().includes('[NoNodes] ** No nodes are available: [http://localhost:9200]'), opacNew2().split('\n').filter((l) => /NoNodes/.test(l)).slice(0, 2).join('\n')) const gNo = ctx.sh(`grep NoNodes ${opacLog} | tail -1`).out ctx.check('grep NoNodes … | tail -1 prints that line', /\[WARN\] \[NoNodes\] \*\* No nodes are available: \[http:\/\/localhost:9200\], called from sub Search::Elasticsearch::Role::Client::Direct::__ANON__ at .*\/Koha\/SearchEngine\/Elasticsearch\/Search\.pm line 101\.$/.test(gNo), gNo) const esStatus = ctx.sh(`koha-es-indexer --status ${I}`) ctx.check('koha-es-indexer --status (not started) → "ES indexing daemon not running for : failed!"', esStatus.out === `ES indexing daemon not running for ${I}: failed!`, esStatus.out) // --- Elasticsearch running, indexes never built -------------------------------------------------------------------- const net = docker('inspect', 'koha-koha-1', '-f', '{{range $k,$v := .NetworkSettings.Networks}}{{$k}}{{end}}').stdout.trim() docker('rm', '-f', 'kbverify-es') docker('run', '-d', '--name', 'kbverify-es', '--network', net, '-e', 'discovery.type=single-node', '-e', 'xpack.security.enabled=false', '-e', 'ES_JAVA_OPTS=-Xms512m -Xmx512m', ES_IMAGE) const esUp = async () => { for (let i = 0; i < 60; i++) { if (ctx.sh('curl -s -m 3 kbverify-es:9200').out.includes('number')) return true; await sleep(3000) } return false } if (!ctx.check('test Elasticsearch 8.17 answers', await esUp())) return ctx.sh('curl -s -XPUT kbverify-es:9200/_cluster/settings -H "Content-Type: application/json" -d \'{"persistent":{"cluster.routing.allocation.disk.threshold_enabled":false}}\' >/dev/null') const health = ctx.sh("curl -sS 'http://kbverify-es:9200/_cluster/health?pretty'").out ctx.check('_cluster/health?pretty → "status" : "green"', /"status" : "green"/.test(health) && health.includes('"number_of_nodes" : 1'), health) ctx.sh(`sed -i -E 's#[^<]*#kbverify-es:9200#' ${conf}`) await plackRestart() const opacNew3 = logFrom(opacLog) const noIndex = search('history') ctx.check('Elasticsearch up, indexes never built → OPAC "No results found!"', noIndex === 'No results found!', noIndex) ctx.check('…plack-opac-error.log: index_not_found_exception / "no such index [koha__biblios]"', /no such index \[koha_\w+_biblios\]/.test(opacNew3()), opacNew3().split('\n').filter((l) => /index/i.test(l)).slice(0, 3).join('\n')) const gMiss = ctx.sh(`grep index_not_found ${opacLog} | tail -1`).out ctx.check('grep index_not_found … | tail -1 → "[WARN] [Missing] ** [http://]-[404] [index_not_found_exception] no such index [koha__biblios], …"', /\[WARN\] \[Missing\] \*\* \[http:\/\/kbverify-es:9200\]-\[404\] \[index_not_found_exception\] no such index \[koha_\w+_biblios\], /.test(gMiss), gMiss) const indices = ctx.sh("curl -sS 'http://kbverify-es:9200/_cat/indices?v'").out ctx.check('_cat/indices?v lists only the header (no koha_ index)', !indices.includes('koha_') && indices.startsWith('health status index'), indices) // Build, restart, found. const plugin = docker('exec', 'kbverify-es', 'bin/elasticsearch-plugin', 'install', '--batch', 'analysis-icu') ctx.check('analysis-icu installed for the rebuild', plugin.stdout.includes('-> Installed analysis-icu'), plugin.stdout + plugin.stderr) docker('restart', 'kbverify-es') await esUp() const build = ctx.sh(`koha-elasticsearch --rebuild -d -v ${I} 2>&1`).out const totals = [...build.matchAll(/Total (\d+) records indexed/g)].map((m) => Number(m[1])) ctx.check('koha-elasticsearch --rebuild -d -v → "Total N records indexed" for biblios and authorities', totals.length === 2 && Math.abs(totals[0] - biblios) <= 5, `${totals.join(', ')} (biblio ${biblios})\n${build}`) const indices2 = ctx.sh("curl -sS 'http://kbverify-es:9200/_cat/indices?v'").out ctx.check(`_cat/indices?v now lists koha_${I}_biblios and koha_${I}_authorities`, indices2.includes(`koha_${I}_biblios`) && indices2.includes(`koha_${I}_authorities`), indices2) const health2 = ctx.sh("curl -sS 'http://kbverify-es:9200/_cluster/health?pretty'").out ctx.check('on one server, health after the build is "yellow" (replicas cannot be placed)', /"status" : "yellow"/.test(health2), health2.split('\n').slice(0, 4).join(' ')) ctx.check('after the build, search returns results (no Plack restart needed)', results('history'), search('history')) }