Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sorting fields inside a document in solr

Tags:

solr

lucene

I am working with a solr index that I have not made. I only have access to the solr admin.

In each document that is returned by the query I write in the solr admin, has around 40 fields. These fields are not sorted alphabetically. Now my question is can I sort them somehow in the solr admin? If I can not, I have the opportunity to import that index locally in my dev machine. I also have access to the config (solr config, data import config etc) files.

Is it possible to do some magic in any of those config files and import locally which will sort them alphabetically?

like image 297
Crime Master Gogo Avatar asked May 11 '26 03:05

Crime Master Gogo


1 Answers

No, neither Lucene or Solr guarantees the order of the fields returned (the order of values inside a multi-valued field is however guaranteed)

You might have luck (you won't - see comment below - fl maintains the same order as in the document) by explicitly using the fl parameter to get the order you want, but that would require maintaining a long list of fields to be returned.

It's usually better to ask why you'd need the order of the fields to maintained. The data returned from Solr is usually not meant for the user directly, and should be processed in your controller / view layer to suit the use case.

like image 77
MatsLindh Avatar answered May 13 '26 20:05

MatsLindh