opensearch suggestions

search suggestionsI previously wrote about creating an opensearch plugin for our library catalogue which could be used in both Firefox 2 and Internet Explorer 7. We’ve been offering this to our patrons for the last five months. I’ve always enjoyed the search suggestions that the default Google plugin in Firefox offers. None of the other plugins I’ve installed offer that feature though I imagine there are some out there. Yesterday, I decided to take a look at what would be involved in adding search suggestions to our plugin.

This mozilla developer document does an excellent job of outlining the steps needed to offer this functionality. In terms of the search plugin itself, it’s just a matter of adding an additional line to the xml file. Then the real work needs to happen on a server somewhere.

Again, there is a mozilla developer document that clearly explains what your server side script needs to do. Basically, it needs to return the suggestions in JSON format. The real question I needed to answer was what should the source of the suggestions be?

At first, I looked to using the aspell dictionary we use for our catalogue spellchecker. However, I could not anchor the suggestions in such a way that aspell would provide useful results. Then it occurred to me that using php/yaz to do a z39.50 scan might be the way to go. Sure enough, a scan of the title index provided some very nice results. And it was trivial to implement taking less than 30 lines of php code to do so.

In some lazy corner of my mind, I’d been originally hoping maybe I could just steal Google’s suggestions for this purpose. After I implemented the z39.50 solution, I realized I could steal Google’s suggestions if I wanted to: the necessary URL appears in the google.xml file in Firefox’s searchplugins folder. However, on subsequent reflection I decided those suggestions would not be particularly relevant since they are based on the contents of arbitrary web pages while our suggestions are based on titles of books in our collection, probably much more relevant.

If you want to try out the new search plugin, go here. It is a blank page but the Firefox search plugin button lights up to indicate you can install a search plugin.

11 comments on opensearch suggestions

  • Dale

    “the Firefox search plugin button lights up” Where is that?

  • The button which normally has the google icon (to the left of the search box in firefox) should show a blue glow when you visit the page I linked to. If you then click on the button, there should be an “add search cambridge libraries” item near the bottom of the menu. Here’s an example of what it looks like (the blue glow disappears when you click the button).

  • Dale

    Found it. I had never even noticed that search box was over there! I didn’t see much point in my being able to search Cambridge libraries, but I added a couple of other search engines there. Thanks!

  • Yeah, you need the DPL search plugin… ;)

  • hey, this is pretty cool. Did you think about returning anything other than titles in the drop-down? When I look at what Google does, it’s more about popular keywords, and less about known items. Just a thought.

  • Yeah, titles may not in fact be the best source of suggestions but it was the best source that was readily available. As I mentioned, you could just use Google’s suggestions but I am not sure they are relevant to library collections. I guess the only way to mimic that would be to do some datamining on your keyword searches but again, the system does not make that particularly easy to do. I’d love to see some other approaches to the problem, though! ;)

  • what are the 30 lines of PHP?

  • Jeff,

    I have emailed you the code.

  • Well done, Mike. I never actually had thought about the search suggestion on the OpenSearch plugin. I suppose that’s partially because I never really use (and therefore, and hardly ever accustomed to) suggestions in my searches.

    I do not have access to a z39.50 account, and highly doubt I would get it – the love of being in a tightly locked library consortia with a central system. Anyhow, had I done it, I would have simply used Google’s suggestion (as it really ends up being a word suggest), and perhaps get some data mining from the searches themselves to build up a data store for future reference.

  • I keep going back and forth on whether using google’s suggestions would be better or worse. I think for some things they’d be better and for others they’d be worse. For now, I’m sticking with the titles. ;)

  • I can see why you’re uncertain – but you did ask how others would do it. ;) Granted, I have little choice, but for something that we haven’t advertised, I think Google would be easiest and a suitable solution (again, if I were to implement this — I might implement it on our actual website redesign however, good idea!).

    Regardless, if there were desire to be really picky, one could always retrieve the first 5 results from personalized data mining, and then the next 5 results from Google. It would require an extra call and more bandwidth, but it’s a tradeoff. You could try to further the data mining to decide which resulted in a better suggestion (somehow, not sure how) if you were really that much of a statistical analyst. ;)