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 d5e1c4c1d7b5d1e5ca60733f15ab6bd8bd3f3821b5318c545f9cccdae4c98c4f) Ran 2026-11-08T11:29:13Z (UTC), 454 s Koha 26.05.05 (Koha::version 26.05.05.000, database version 26.0505000) Source https://git.koha-community.org/Koha-community/Koha/src/commit/d3fc229bc5eaea25dfe88f86149386408fe5d32d System Ubuntu 24.04.5 LTS Setup A fresh Ubuntu 24.04 server with Koha installed as our installation guide leaves it (Plack on), reached over SSH as the sudo user librarian. Result PASS: all 30 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 server box starts with Koha installed as the guide leaves it ok (setup) the sample catalogue loaded and indexed seen: exit=0 | 1095 ok the SearchEngine query → value / Zebra (a boxed table on a terminal) seen: +-------+ | value | +-------+ | Zebra | +-------+ ok healthy baseline: OPAC search for "history" returns results seen: Your search returned 60 results ok sudo koha-zebra --status → " * Zebra running for library … [ OK ]" seen: * Zebra running for library [ OK ] ok sudo koha-zebra --stop without -v prints nothing seen: exit=0 ok stopped: " * Zebra not running for library … [fail]", exit 3 seen: * Zebra not running for library [fail] [exit 3] ok Zebra stopped → OPAC "No results found!" seen: No results found! ok … the page says "No results found for that in catalog." and shows no error seen: No results found! No results found for that in catalog. ' → localhost:9200 and koha_library seen: localhost:9200 koha_library ok SearchEngine Elasticsearch, server down → OPAC "No results found!" seen: No results found! ok sudo grep NoNodes plack-opac-error.log | tail -1 → "[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 N." seen: [2026/11/08 11:36:29] [WARN] [NoNodes] ** No nodes are available: [http://localhost:9200], called from sub Search::Elasticsearch::Role::Client::Direct::__ANON__ at /usr/share/koha/lib/Koha/SearchEngine/Elasticsearch/Search.pm line 101. ok sudo koha-es-indexer --status (never started) → "ES indexing daemon not running for library" … [fail] seen: * ES indexing daemon not running for library [fail] exit=3 == 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, on a real server since 2026-11-08 (plan212 P3.9). * * A fresh Ubuntu 24.04 server with Koha installed as the installation guide leaves it (box.mjs kohaBoxCheck), reached * over SSH as the sudo user `librarian`, with Koha's sample catalogue loaded from our R2 fixture (setup, as in * koha-rebuild-zebra-index.mjs). Search is broken each way the article covers and fixed the way it says: * A. Zebra stopped; B. stopped while Plack holds connections; C. --restart with connections open; D. the index * emptied (zebraidx init) and rebuilt; E. SearchEngine = Elasticsearch with nothing listening on localhost:9200. * NOT here: "Elasticsearch up, indexes never built" and koha-elasticsearch --rebuild need a running Elasticsearch, which * does not fit the 4 GB box beside Koha; those panels keep their 2026-11-06 live-Koha run (plan212 P4.2: the VPS). * Searches and the staff interface are read over curl on the box (the staff password stays on the box). */ import { kohaBoxCheck } from './server-box/box.mjs' /** liveKoha: false — runs only on its own server box, so kb:verify neither starts nor reads live Koha. */ export const meta = { koha: '26.05.05', passed: '2026-11-08', liveKoha: false } const I = 'library' const FIXTURE = 'https://cdn.myopac.com/kohasolutions/kb-fixture/koha-sample-biblios-2605-96b40122.mrc' const sleep = (ms) => new Promise((r) => setTimeout(r, ms)) // milliseconds export default (ctx) => kohaBoxCheck(ctx, async ({ run, L }) => { const sql = (q) => L(`sudo koha-mysql ${I} -N -B -e "${q}"`) const opacLog = `/var/log/koha/${I}/plack-opac-error.log` const zlog = `/var/log/koha/${I}/zebra-error.log` const OPAC = "-H 'Host: library.example.org' http://localhost" const search = (q = 'history') => L(`curl -s -m 60 ${OPAC}/cgi-bin/koha/opac-search.pl?q=${q} | grep -o -E 'No results found!|Your search returned [0-9]+ results' | head -1`) const results = () => /Your search returned [1-9]/.test(search()) const zebraUp = () => /Zebra running/.test(L(`sudo koha-zebra --status ${I}`)) && !/not running/.test(L(`sudo koha-zebra --status ${I}`)) const untilZebra = async (want) => { for (let i = 0; i < 40; i++) { if (zebraUp() === want) return true; await sleep(500) } return false } const plackR = async () => { L(`sudo koha-plack --restart ${I} >/dev/null 2>&1`); for (let i = 0; i < 30; i++) { await sleep(2000); if (L(`curl -s -o /dev/null -w '%{http_code}' ${OPAC}/cgi-bin/koha/opac-main.pl`) === '200') return } } const lines = (f) => Number(L(`sudo wc -l < ${f}`)) // ------------------------------------------------------------------ setup: a catalogue const load = L(`curl -sf -o /tmp/kbv-sample.mrc ${FIXTURE} && chmod 644 /tmp/kbv-sample.mrc && sudo koha-shell ${I} -c "perl /usr/share/koha/bin/migration_tools/bulkmarcimport.pl -b -file /tmp/kbv-sample.mrc" >/tmp/kbv-import.log 2>&1; echo "exit=$?"`) const biblios = Number(sql('SELECT COUNT(*) FROM biblio')) ctx.check('(setup) the sample catalogue loaded and indexed', load.endsWith('exit=0') && biblios > 1000, `${load} | ${biblios}`) L(`sudo koha-rebuild-zebra -f -b ${I} >/dev/null 2>&1`); await plackR() // ------------------------------------------------------------------ step 1 const engine = run(`sudo koha-mysql ${I} -e "SELECT value FROM systempreferences WHERE variable='SearchEngine';"`) ctx.check('the SearchEngine query → value / Zebra (a boxed table on a terminal)', /\|\s*value\s*\|/.test(engine.out) && /\|\s*Zebra\s*\|/.test(engine.out), engine.out) ctx.check('healthy baseline: OPAC search for "history" returns results', results(), search()) const st0 = L(`sudo koha-zebra --status ${I}`) ctx.check('sudo koha-zebra --status → " * Zebra running for library … [ OK ]"', /Zebra running for library/.test(st0) && !/not running/.test(st0), st0) // ------------------------------------------------------------------ A. Zebra not running await plackR() const zSize = L(`sudo stat -c %s ${zlog}`) const from = lines(opacLog) const stop = L(`sudo koha-zebra --stop ${I}; echo "exit=$?"`) ctx.check('sudo koha-zebra --stop without -v prints nothing', stop === 'exit=0', stop) await untilZebra(false) const st = run(`sudo koha-zebra --status ${I}`) ctx.check('stopped: " * Zebra not running for library … [fail]", exit 3', /Zebra not running for library/.test(st.out) && st.exit === 3, `${st.out} [exit ${st.exit}]`) ctx.check('Zebra stopped → OPAC "No results found!"', search() === 'No results found!', search()) const page = L(`curl -s -m 60 ${OPAC}/cgi-bin/koha/opac-search.pl?q=history | sed -e 's/<[^>]*>/ /g' | tr -s ' \\n' ' '`) ctx.check('… the page says "No results found for that in catalog." and shows no error', /No results found for that in catalog\./.test(page) && !/\berror\b/i.test(page.replace(/errors?\/404/g, '')), (page.match(/No results found.{0,60}/) ?? [''])[0]) const staff = L(`P=$(sudo cat /root/kb-staff-password); H='Host: library-intra.example.org'; U=http://localhost:8080/cgi-bin/koha; rm -f /tmp/j tok=$(curl -s -H "$H" -c /tmp/j -b /tmp/j $U/mainpage.pl | grep -o 'name="csrf_token" value="[^"]*"' | head -1 | sed 's/.*value="//;s/"//') curl -s -H "$H" -c /tmp/j -b /tmp/j -o /dev/null --data-urlencode login_userid=koha --data-urlencode "login_password=$P" --data "login_op=cud-login&koha_login_context=intranet&csrf_token=$tok" $U/mainpage.pl curl -s -H "$H" -c /tmp/j -b /tmp/j "$U/catalogue/search.pl?q=history" | sed -e 's/<[^>]*>/ /g' | tr -s ' \\n' ' ' | grep -o 'No results match your search[^.]*' | head -1`) ctx.check('… the staff interface also finds nothing ("No results match your search")', /No results match your search/.test(staff), staff) const [bn, title] = sql('SELECT biblionumber, title FROM biblio ORDER BY biblionumber LIMIT 1 OFFSET 16').split('\t') const detail = L(`curl -s -m 60 ${OPAC}/cgi-bin/koha/opac-detail.pl?biblionumber=${bn} | grep -c -F '${(title ?? '').replace(/[^A-Za-z0-9 ]/g, ' ').trim().split(' ')[0]}'`) ctx.check(`… but a record opens by its number (opac-detail.pl?biblionumber=${bn}, "${title}")`, /[1-9]\d*$/.test(detail), detail.slice(-20)) const opacNew = L(`sudo tail -n +${from + 1} ${opacLog}`) ctx.check('… and no log says why: zebra-error.log unchanged, no Zebra/ZOOM line in plack-opac-error.log', L(`sudo stat -c %s ${zlog}`) === zSize && !/zebra|zoom|connect/i.test(opacNew), opacNew.slice(0, 300)) const start = run(`sudo koha-zebra -v --start ${I}`) ctx.check('sudo koha-zebra -v --start library → " * Starting Koha Zebra daemon for library … [ OK ]"', /Starting Koha Zebra daemon for library/.test(start.out) && start.exit === 0, start.out) await untilZebra(true); await sleep(1000) ctx.check('Zebra started → search returns results again, no rebuild needed', results(), search()) // ------------------------------------------------------------------ B. stopped while Plack holds connections for (let i = 0; i < 3; i++) search() const vstop = L(`sudo koha-zebra -v --stop ${I}`) ctx.check('sudo koha-zebra -v --stop → " * Stopping Koha Zebra daemon for library … [ OK ]"', /Stopping Koha Zebra daemon for library/.test(vstop), vstop) await sleep(5000) const half = L(`sudo koha-zebra --status ${I}`) ctx.check('… with connections open, --status may still say running while every search finds nothing', search() === 'No results found!', `${half} | ${search()}`) const refused = L(`sudo koha-zebra -v --start ${I}`) ctx.capture(`sudo koha-zebra -v --start ${I}`, refused) ctx.check('… -v --start answers "Error: Zebra already running for library … [fail]" (or starts, once the leftovers are gone)', /Error: Zebra already running for library|Starting Koha Zebra daemon for library/.test(refused), refused) const pr = run(`sudo koha-plack --restart ${I}`) ctx.check('sudo koha-plack --restart → Stopping / Starting Plack daemon for library, each [ OK ]', (pr.out.match(/\[ OK \]/g) ?? []).length === 2, pr.out) await sleep(3000) if (!zebraUp()) L(`sudo koha-zebra -v --start ${I}`) await untilZebra(true); await sleep(1000) ctx.check('… and then -v --start brings search back', results(), search()) // ------------------------------------------------------------------ C. --restart with connections open for (let i = 0; i < 3; i++) search() const rs = run(`sudo koha-zebra -v --restart ${I}`) await sleep(4000) const afterRs = search() ctx.check('sudo koha-zebra -v --restart with connections open → "Stopping…" then "Starting…" or "Error: Zebra already running…" (the latter leaves search empty)', /Stopping Koha Zebra daemon for library/.test(rs.out) && (/Starting Koha Zebra daemon for library/.test(rs.out) || (/Error: Zebra already running for library/.test(rs.out) && afterRs === 'No results found!')), `${rs.out} | ${afterRs}`) await plackR(); await sleep(2000); if (!zebraUp()) L(`sudo 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(), search()) // ------------------------------------------------------------------ D. an emptied index const cfg = `/etc/koha/sites/${I}/zebra-biblios-dom.cfg` L(`sudo 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" >/dev/null 2>&1`) ctx.check('index emptied (zebraidx init): Zebra and the indexer still report running, every search finds nothing', zebraUp() && /Indexer running/.test(L(`sudo koha-indexer --status ${I}`)) && search() === 'No results found!', search()) const rb = run(`sudo koha-rebuild-zebra -f -v -b ${I}`) const exported = Number(rb.out.match(/Records exported: (\d+)/)?.[1] ?? NaN) ctx.check('sudo koha-rebuild-zebra -f -v -b: "Records exported: N" equal to COUNT(*), "Indexing complete:"', rb.out.includes('Indexing complete:') && exported === biblios, `exported ${exported}, biblio ${biblios}`) await sleep(3000) const afterRb = search() await plackR(); await sleep(2000); if (!zebraUp()) L(`sudo 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 the rebuild: ${afterRb}]`, results(), search()) const count = run(`sudo koha-mysql ${I} -e "SELECT COUNT(*) FROM biblio;"`) ctx.check('sudo koha-mysql … COUNT(*) → the same number (boxed)', new RegExp(`\\|\\s*${biblios}\\s*\\|`).test(count.out), count.out) // ------------------------------------------------------------------ E. Elasticsearch selected, nothing listening const h0 = run("curl -sS 'http://localhost:9200/_cluster/health?pretty'") ctx.check('nothing on localhost:9200 → "curl: (7) Failed to connect to localhost port 9200 after N ms: Couldn\'t connect to server" (curl 8.5 on Ubuntu 24.04; newer curl says "Could not"), exit 7', h0.exit === 7 && /^curl: \(7\) Failed to connect to localhost port 9200 after \d+ ms: Could(?:n't| not) connect to server$/.test(h0.out), h0.out) const g = run(`sudo grep -A3 '' /etc/koha/sites/${I}/koha-conf.xml`) ctx.check("sudo grep -A3 '' → localhost:9200 and koha_library", g.out.includes('localhost:9200') && g.out.includes('koha_library'), g.out) // preferences are cached in memcached: restart it after the SQL change (setup, not shown) sql("UPDATE systempreferences SET value='Elasticsearch' WHERE variable='SearchEngine'"); L('sudo systemctl restart memcached'); await plackR() const from2 = lines(opacLog) ctx.check('SearchEngine Elasticsearch, server down → OPAC "No results found!"', search() === 'No results found!', search()) const gNo = run(`sudo grep NoNodes ${opacLog} | tail -1`) ctx.check('sudo grep NoNodes plack-opac-error.log | tail -1 → "[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 N."', lines(opacLog) > from2 && /\[WARN\] \[NoNodes\] \*\* No nodes are available: \[http:\/\/localhost:9200\], called from sub Search::Elasticsearch::Role::Client::Direct::__ANON__ at \/usr\/share\/koha\/lib\/Koha\/SearchEngine\/Elasticsearch\/Search\.pm line \d+\.$/.test(gNo.out), gNo.out) const es = L(`sudo koha-es-indexer --status ${I}; echo "exit=$?"`) ctx.check('sudo koha-es-indexer --status (never started) → "ES indexing daemon not running for library" … [fail]', /ES indexing daemon not running for library/.test(es), es) })