Closed kstapelfeldt closed 1 year ago
Repo: ajax_solr_search/sort
An implementation of the sorting feature can be found at the link above. The SortSelectWidget
features a dropdown menu that allows users to sort their search results based on the configured sort criteria. The sort criteria can be configured on the federated search config form at /admin/config/search/ajax_solr
under the Sort Criteria section. The order in which the sort criteria is displayed in the dropdown can be modified by rearranging the order of the field entries on the form. A sample configuration can be found in README.md.
Solr does not support sorting on multivalued fields. Currently, the config form allows users to select multivalued fields as sort criteria, but if they try to select them when sorting, the results will appear to load indefinitely (Solr returns Error 400 bad request).
I created a patch [sort_criteria.patch] that prevents this by removing multivalued fields from the list of available fields when configuring sort criteria. I've tested this against my local Solr server with proxy disabled, but I'm not able to test it with proxy enabled so it hasn't been committed yet.
Also, I found a workaround for sorting on multivalued fields using function queries (see: field Function), however, this only works for numeric fields and can't be used for Text/String fields.
The patch file [sort_criteria.patch] currently does not work with proxy enabled. (It's using the wrong Solr url for the curl requests)
Todo: Add schema/fields/
route to the routes yaml file and add the FilterOutMultivaluedFields function to Proxy Controller.
Sorting by string
fields in Solr is case-sensitive. I was not able to find a way to override this behaviour by modifying the queries themselves. I'm using the Default Solr content index for Islandora Lite, and most of the single-valued text fields seem to be stored as string
so this might be an issue when sorting by fields such as title. I tried indexing title as Fulltext but all the Fulltext options are multivalued which can't be used for sorting.
A possible solution could be to use solr.LowerCaseFilterFactory
but that can only be used for Text fields and not String fields. Also, this approach would require modifying the Solr schema.
Sort by title, relevance, date, etc