a glossary facet
Experimental Project

This is a sandbox project, which contains experimental code for developer use only.

I was surprised to find that there wasn't a glossary facet that would provide an A-Z listing. I know views offers similar functionality, but thought it would be useful to have as a facet. I've attached my solution here.

This module will create a new Apache Solr index based on the first letter of node title. It then creates a new facet based on that index. Lastly, it strips the count from the items, and adds in any letters missing from the A-Z list so that you have a complete alphabet to display where only the letters that have items will be links.

Some suggestions to make this better would be as follows:
1) Set $glossary_key outside of glossary_facet_apachesolr_index_document_build() so that the name of this facet could be changed more easily. I started playing with this, but it started throwing errors and I don't have time at the moment to fix.
2) I didn't change the way that the facet was being returned at all. This means that in glossary_facet_block_view_alter() this code expects the string returned to be in a certain format. If that changes at some point in a facet api upgrade this will no longer work.
3) Getting this into the UI as a widget that could then use any existing indexed information as its base could be a better solution that what I've provided here (grab the first letter of each item after being returned by Solr as opposed to indexing just the first letter).

-Apache Solr
-Facet API

Project Information