sortingsolrrelevancefaceted-searchhierarchy

I need to sort the facets that come back from SOLR by relevancy


I have within my SOLR index song objects which belong to a higher level album object. An example is shown below:

<song>
<album title>Blood Sugar Sex Magic</album title>
<song title>Under the Bridge</song title>
<description>A sad song about junkies</description>
</song>

What I can do at the moment is create a facet on the album title so that a search on songs will also show me what albums contain hits for that keyword.

The default behaviour for SOLR is that the facets are shown in the order of most hits to least. However what I want to achieve is the facet list to be sorted according to the relevancy of the top hit for that album.

For example a search on the word "sad" may show a facet with one hit for "Blood Sugar Sex Magic" and there may also be an album called "Sad Clown songs" where there are 10 hits. "Sad clown songs" will show as the first facet even though it may be that "Under the bridge" comes up as the most relevant song.

My question is how can I get all the facets back but then have them ordered by the relevancy of the songs within them? If I would need to change or extend some underlying SOLR code what would that be?

Thanks in advance.


Solution

  • Solr can only sort facets in lexicographical order or by count (see the facet.sort parameter).

    If you want to implement a different sort order I'd start in the SimpleFacets class.