Thumbnails and links to annotations now working
Finally got the thumbnails working: had to use negative margins on the enclosing div, rather than on the image itself. Tweaked the code a little more to get rid of duplicate returns, and then added functionality so that when you click on a hit which is inside an annotation area, you go directly to the image, with that annotation popping up for you.
Then I worked on getting the category selection list going. It was a bit complicated because the distinct-values we want to test on are attribute values, but the rendered option text we need for the drop-down is the content of a child element. In the end I got it working, so the select element is there on the search page, but at the moment it does nothing. It needs to be hooked up to a block of code which will restrict the text search based on the category, or, if there's no search text, will restrict the document list to those which have annotations in that category.