digitalutsc / ajax_solr_search

Drupal 8/9 module provide Federated Search with a shared Solr core. It also integrates Ajax Solr library to Drupal.
Apache License 2.0
0 stars 2 forks source link

digitalutsc/islandora_lite_docs#65 Add sorting to federated search #10

Closed amym-li closed 1 year ago

amym-li commented 1 year ago

Changes

New: SortSelectWidget.js

This PR introduces a widget that allows users to sort search results based on the configured sort criteria. The sort criteria can be configured on the federated search form at /admin/config/search/ajax_solr under the Sort Criteria tab. The order of the sort options can be modified by rearranging the field entries on the form. The widget creates options for sorting by ascending and descending for each field entry. The default sort is set to the first entry in the dropdown. If no fields are entered under Sort Criteria, the sorting dropdown will not display.

Notes:

Multivalued Sorting

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.