Sort by multiple fields in a specific order in Solr

So, I want to sort my Solr request by the following fields:

  • published_year (desc)
  • series_number (asc)
  • status_color

The problem is that status_color needs to be sorted by the following values ​​(e. And not in alphabetical order):

  • "Green"
  • "Yellow"
  • "Red"

This field can contain only one of these values.

I hope this helps to do this in a Solr request instead of massaging the result in code. As a result of hundreds of thousands of documents, this is not an option.

Any help is appreciated.

+5
source share
2 answers

I think the answer to this question will also be for you:

Is it possible to specify the order of documents in solr

+3
source

I believe Solr has Enum types , although I have never seen them use it for a while. But they would be the perfect combination, so it’s worth a try.

+3
source

Source: https://habr.com/ru/post/1204644/


All Articles