Last week Stanford open sourced the code responsible for the Nearby on Shelf feature in SearchWorks as the Blacklight Browse Nearby gem. This feature has been highly sought after by various Blacklight institutions to be contributed back to the community. In keeping with the spirit of the vibrant open source community around Blacklight, Stanford has contributed the development effort to get this codebase available for use and contribution by other Blacklight implementers.
The release of this software was the culmination of a re-write of the SearchWorks code making it an installable package, more generalizable, and suitable in an open source context. Due to that fact, the end product is much more generic that SearchWorks' version (as you can see in the side-by-side screenshots below with SearchWorks being on the right) however it is infinitely more customizable.
The aim of this gem is to get around the inability of the indexing technology behind SearchWorks (Apache Solr) to retrieve documents "behind" a given document in a sorted list. This library, combined with an indexing technique for generating sort/reverse keys, makes it possible to retrieve documents "behind" and/or "in front" of a given document.
The codebase for the Blacklight Browse Nearby gem is available on GitHub under an Apache 2 license at: https://github.com/projectblacklight/blacklight_browse_nearby
You can find plenty more information in the README files located in the link above about the gem and the approach that we took with generating sort keys in solr to support this behavior.