Week Beginning 29th January 2024
I spent a lot of time this week working on the Books and Borrowing project, making final preparations for the launch of the full website. By the end of the week the website was mostly publicly available (see https://borrowing.stir.ac.uk) but it wasn’t as smooth a process as I was hoping for and there are still things I need to finish next week.
My first task of the week was to write a script that identified borrowers who have at least one active borrowing record but of these zero are records on pages that are active in registers that are active. This should then bring back a list of borrowers who are only associated with inactive registers. It took quite some time to get my head around this after several earlier attempts didn’t do exactly what was requested and my final script identified 128 borrowers that were then deactivated, all from St Andrews.
I then moved on to an issue that had been noticed with a search for author names. A search for ‘Keats’ was bringing back matches for ‘Keating’, which was clearly not very helpful. The cause of this was Solr trying to be too helpful. The author name fields were stored at ‘text_en’ and this field type has stemming applied to it, whereby stems of words are identified (e.g. ‘Keat’) and a search for a stem plus a known suffix (e.g. ‘s’, ‘ing’) will bring back other forms of the same stem. For names this is hopeless as ‘Keating’ is in no way connected to ‘Keats’.
It turned out that this issue was affecting many other fields as well, such as book titles. A search for ‘excellencies’ was finding book titles containing the forms ‘excellency’ and also ‘excellence’, which again was pretty unhelpful. I did some investigation into stemming and whether a Solr query could be set to ignore it, but this did not seem to be possible. For a while I thought I’ve had to change all of the fields to strings, which would have been awful as strings in Solr are case sensitive and do not get split into tokens, meaning wildcards would need to be used and the search scripts I’d created would need to be rewritten.
Thankfully I discovered that if I stored the text in the field type ‘text_general’ then stemming would be ignored but the text would still be split into tokens. I created a test Solr index on my laptop with all of the ‘text_en’ fields set to ‘text_general’ and searching this index for author surname ‘Keats’ only brought back ‘Keats’ and book title for ‘excellencies’ only brought back ‘excellencies’. This is exactly what we wanted and with the change in place I was able to fully regenerate the cached data and the JSON files for import into Solr (a process that takes a couple of hours to complete) and ask for the online Solr index to be updated.
I also updated the help text on the website, adding in some new tooltips about editors and translators to the advanced search form. With no other issues reported by the team I then began the process of making the site live, including adding a ‘quick search’ bar to the header of all pages, adding in menu items to access the data and adding the ‘on this day’ feature to the homepage.
However, I noticed one fairly sizeable issue, unfortunately. The stats on the ‘facts’ page do not correspond to the results you get when you click through to the search results. I therefore removed the top-level ‘Facts & figures’ menu item until I can figure out what’s going on here. I first noticed an issue with the top ten genre lists. The number of borrowings for the most popular genre (history) were crazy. Overall borrowings of ‘history’ is listed as ‘104849’, which almost as many as the total number of borrowing records than we have in the system. Also the link to view borrowings in the search was limiting the search to Haddington, which is clearly wrong. Other numbers in the page just weren’t matching up to the search results either. For example for Chambers the most prolific borrower is Mrs Thomas Hutchings with 274 listed borrowings, but following the link to the search results gives 282.
It took several hours of going through the code to ascertain what was going on with the top ten genre issue and it was all down to a missing equals sign in an ‘if’ statement. Where there should have been two (==) there was only one, and this was stopping the following genre code from processing successfully.
There is unfortunately still the issue of the figures on the facts pages not exactly matching up with the number of results returned by the search. I had noticed this before but I’d hoped it was caused by the database still being updated by the teasm and being slightly out of sync with the Solr index. Alas, it’s looking like this is not the case. There must instead be discrepancies in the queries used to generate the Solr index and those used the generate the facts data. I fear that it might be the case that in the chain of related data some checks for ‘isactive’ have been omitted. Each register, page, borrowing record, borrower, author, and book at each level has its own ‘isactive’ flag. If (for example) a book item is set to inactive but a query fails to check the book item ‘isactive’ flag then any associated borrowing records will still be returned (unless they have each been set to inactive). I’m going to have to check every query to ensure the flags are always present. And it’s even more complicated than that because queries don’t necessarily always include the same data types. E.g. a borrower is related to a book via a borrowing record and if you’re only interested in borrowers and books the query doesn’t need to include the associated page or register. But of course if the page or register where the borrowing record is located is inactive then this does become important. I might actually overhaul the ‘facts’ so they are generated directly from the Solr index. This would mean things should remain consistent, even when updates are made to the data in the CMS (these would not be reflected until the Solr index is regenerated). Something I’ll need to work on next week.
Also this week I had a Zoom call with Jennifer Smith and Mary Robinson to discuss expanding the Speak For Yersel project to other areas, namely Wales, Ireland and Northern Ireland. The data for these areas is now ready to use and we agreed that I would start working with it next week.
I also fixed a couple of issues with the DSL website. The first was an easy one – the team wanted the boxes on the homepage to be updated to include a ‘Donate’ box. It didn’t take long to get this done. The second was an issue with Boolean searches on our test site. Performing a fulltext search for ‘letters and dunb’ on the live site was returning 192 results while the same search on our test site was returning 54,466 results (limited to 500).
It turned out that the search string was being converted to lower case before it was being processed by the API. I must have added this in to ignore case in the headword search, but an unintended consequence was that the Booleans were also converted to lower case and were therefore not getting picked up as Booleans. I updated the API so that the search string is not converted to lower case, but where a headword search is to be performed the string is converted to lower case after the Boolean logic is executed. With the update in place the searches started working properly again.
I also made a minor tweak to the advanced search on both live and new sites so that query strings with quotations in them no longer lose their quotation marks when returning to the advanced search form. This was an issue that was identified at our in-person meeting a couple of weeks ago.
I found a bit of time to continue working on the new map for the Place-names of Iona project this week too, during which I completed work on the ‘Table view’ feature. I updated the table’s popup so that it never becomes taller than the visible map. If the table is longer than this then the popup now features a scrollbar, which works a lot better than the previous method, whereby pressing on the browser’s scrollbar closed the popup.
I have also now completed the option to press on a place-name in the table to view the place-name on the map. It took a lot of experimentation to figure out how to get the relevant marker popup to open and also populate it with the correct data. Things went a little crazy during testing when opening a popup was somehow getting chained to any subsequent popup openings, resulting in the map getting stuck in an endless loop of opening and closing different popups and attempting to autoscroll between them all. Thankfully I figured out what was causing this and sorted it. Now when you press on a place-name in the table view any open popups are closed, the map navigates to the appropriate location and the relevant popup opens. Originally I had the full record popup opening as well as the smaller marker popup, but I began to find this quite annoying as when I pressed on a place-name in the table what I generally wanted to see was where the place-name was on the map, and the full record obscured this. Instead I’ve set it to open the marker popup, which provides the user with an option to open the full record without obscuring things. I’ve also now made it possible tocite / bookmark / share the table in a URL.
I then moved onto developing the ‘Download CSV’ option, which took quite some time. The link at the bottom of the left-hand menu updates every time the map data changes and pressing on the button now downloads the map data as a CSV.
Also this week I had discussions with the Anglo-Norman Dictionary team about a new proposal they are putting together and I updated the Fife Place-names website to fix a couple of issues that had been introduced when the site was migrated to a new server. I also continued to migrate the collection of Scots poems discussed in previous weeks from ancient HTML to XML, although I didn’t have much time available to spend on this.