Re: search/retrieve via url against my koha catalog
Hi Eric, It's great to see you trying things out. I'm not sure what you mean by "I used Koha's administrative interface to turn on the SRU server", since Koha doesn't provide a public SRU server out of the box currently. Could you elaborate on that? I imagine you might find this one interesting: Bug 42952 - Public SRU with OPAC logic out-of-the-box (https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42952) I haven't completed the work yet but I've been playing around a bit with SRU lately using an Apache proxy and the z3950_responder.pl script. Terry Reese of MarcEdit fame said he found it odd that Koha didn't have a public Z39.50/SRU out of the box and I took his point there. Z39.50 can be a bit tricky because of the networking involved, but SRU is very doable. And with OPAC business logic... it should be roughly equivalent to searching the OPAC using the web UI. (Keep in mind right now z3950_responder.pl and Zebra SRU/Z39.50 services do not honour any of Koha's business logic.) David Cook Lead Software Engineer Prosentient Systems Suite 7.03 6a Glen St Milsons Point NSW 2061 Australia Office: 02 9212 0899 -----Original Message----- Message: 2 Date: Wed, 28 Oct 2026 13:40:19 -0400 From: Eric Lease Morgan <eric_morgan@infomotions.com> Subject: [Koha] search/retrieve via url against my koha catalog To: koha <koha@lists.katipo.co.nz>, koha-devel <koha-devel@lists.koha-community.org> Message-ID: <EEDA574B-6C24-484B-BCCD-299C8E72FF48@infomotions.com> Content-Type: text/plain; charset=us-ascii I have begun implementing an SRU client against my Koha catalog. See: http://index.distantreader.org My Koha catalog includes about 1.4 million records. About 2/3 of them are MARC records describing scholarly open access journal articles. About 1/3 of them are MARC records describing open access and public domain etexts ("books"). My bare-bones catalog interface can be seen at http://catalog.distantreader.org As you may or may not know, SRU (Search/Retrieve via URL) is a Web services protocol used to query things like library catalogs. See: https://www.loc.gov/standards/sru/ I used Koha's administrative interface to turn on the SRU server, and then I patched the SRU server's source code so the server supports facets: https://gist.github.com/a-roussos/cdafddf9554b4b9f9a5a1d353e027be7 With these things in place, I then wrote two XSL stylesheets. The first transforms an SRU Explain request into a human readable search form. The second transforms an SRU SearchRetrieve request into a set of human readable search results. Temporarily, see: https://distantreader.org/tmp/explain.txt https://distantreader.org/tmp/searchRetrieve.txt Consequently, when you go to the following URL, you are presented with a rudimentary form allowing you to query my Koha catalog: http://index.distantreader.org The server supports a query language called CQL (Common Query Language) which is very expressive but requires practice. Example queries include: libraries libraries and privacy libraries and dc.subject=privacy libraries and dc.subject=privacy and koha.itemtype=article Search results include rudimentary bibliographic information as well as links to the full text of given items, usually. ;-) Why is this cool? It is cool because the SRU server returns results as a well-formed and valid XML stream, and consequently the search results can be transformed in a whole bunch of different ways. For example, I created a command-line SRU client that takes a query as input (like the ones above), searches my catalog, finds all results, and downloads the full text to a folder. Thus, my query returns each item found plus their bibliographic details. Temporarily see: https://distantreader.org/tmp/reader-sru-retrieve.py This paves the way for distant reading. For example, the following query downloads the whole of Plato's works, and it does it in less than thirty seconds: dc.author=plato and koha.ccode=alex My next step will be to finish refining an even more refined SRU interface to my catalog using a technology called MCP (Model Context Protocol). This will facilitate two things. First, it will eliminate the need to know CQL, and second, it will evaluate search results and make them much more meaningful. koha++ A very very functional bibliographic catalog. Thank you! -- Eric Lease Morgan <eric_morgan@infomotions.com>
On Oct 29, 2026, at 6:37 PM, David Cook via Koha <koha@lists.katipo.co.nz> wrote:
I'm not sure what you mean by "I used Koha's administrative interface to turn on the SRU server", since Koha doesn't provide a public SRU server out of the box currently. Could you elaborate on that?
I imagine you might find this one interesting: Bug 42952 - Public SRU with OPAC logic out-of-the-box (https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42952)
I haven't completed the work yet but I've been playing around a bit with SRU lately using an Apache proxy and the z3950_responder.pl script. Terry Reese of MarcEdit fame said he found it odd that Koha didn't have a public Z39.50/SRU out of the box and I took his point there. Z39.50 can be a bit tricky because of the networking involved, but SRU is very doable. And with OPAC business logic... it should be roughly equivalent to searching the OPAC using the web UI. (Keep in mind right now z3950_responder.pl and Zebra SRU/Z39.50 services do not honour any of Koha's business logic.)
First of all, I have not been ignoring you, just a bit busier than usual. Second, I stand corrected. I did not turn on SRU via the administrative interface. Instead, a couple of years ago, I probably read a Koha wiki posting about SRU and turned it on via the command line. [1] I then wrote a few Baroque style sheets thus implementing an SRU thin client. Finally, I documented the process in a blog posting. [2] In that posting, I too took advantage of Apache's VirtualHost configuration to simplify the HTTP -> SRU interaction. virtualhost++ Third, since then, rude Internet crawlers found my site, crawled each and every link generated by my Baroque style sheets, and brought my tiny Koha-hosting computer to its knees. Consequently, I have been rewriting my style sheets to be less expressive at the cost of putting greater onus on people to submit CQL queries. See the refined but still in process interface. [3] Next, alas, I do not know anything about the SRU's ability to understand Koha's business logic. Since my Koha catalog has zero patrons and zero items to be checked out (everything is available online), I don't think I have any business logic. 8-) I simply used Koha to index my content, and the Koha catalog interface comes along for the ride. Finally, I will be advocating the use of an MCP interface to the SRU interface. I will advocate this because the MCP/LLM combination does a very good job at interpreting the faceted output as well as the search results. The combination identifies all sorts of patterns in the output that would be difficult for me to articulate by myself, and moreover, the combination does so almost immediately. Continued fun with Koha and SRU. Links [1] wiki posting - https://wiki.koha-community.org/wiki/Setting_up_the_Z39.50_and_SRU_Server [2] blog posting - https://distantreader.org/blog/reader-index/ [3] refined interface - http://index.distantreader.org -- Eric Morgan <eric_morgan@infomotions.com>
participants (2)
-
David Cook -
Eric Lease Morgan