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.
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.
In the end, we decided the easiest way to do this without needing to modify SOLR source code, would be to query solr, ask for the facets then iterate through the results.
Not ideal, but works for now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With