[MGNLEESOLR-79] Support for multiple Solr sort fields Created: 02/Sep/15  Updated: 18/Dec/17

Status: Open
Project: Solr Search Provider
Component/s: None
Affects Version/s: 3.0
Fix Version/s: 3.0.1

Type: Improvement Priority: Neutral
Reporter: Edgar Vonk Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Epic Link: Solr support issues

 Description   

Hi,

We have a use case in our project where we need to implement sorting based on multiple fields (e.g. last name and second name).

Solr supports this just fine and Solr4j does as well (SolrQuery#addSort instead of SolrQuery#setSort). However the Magnolia Solr Module does not unfortunately. In the FacetedSearchResultModel there is only a 'setSortField' method and in FacetedSearchProvider this is used as follows:

 if (model.getSortField() != null) {
            SolrQuery.SortClause sortClause = SolrQuery.SortClause.create(model.getSortField(), ORDER.asc);
            solrQuery.setSort(sortClause);

It should be fairly easy to also add a addSortField method in the FacetedSearchResultModel and use this accordingly in the FacetedSearchProvider making use of the SolrQuery#addSort method?

PS: we would like to override the FacetedSearchProvider class ourselves and implement this sorting but alas the FacetedSearchProvider class is still very very hard to extend. Mainly because almost all methods are private (why not make them protected? I think protected should be the default, not private) but also because some methods (like prepareSolrQuery) are very large indeed. Splitting them up into multiple protected methods would make it much easier for us to extend and customise the class.

An example of a Solr query we would be looking for with multiple sort fields is:

http://eaiw02t.hf.info.nl:8983/solr/eaie-web-collection/select?q=martin&wt=json&indent=true&fq=type%3AindexerMembers&sort=memberLastName+asc,memberFirstName+asc


 Comments   
Comment by Edgar Vonk [ 03/Sep/15 ]

Just a little more nagging. Think I said this before but for us it would be very helpful not only to make all methods in 'outward facing' Java classes protected or public but also the static class variables. E.g. in our code we now need to redefine the 'additionalFilter' static string simply because it is private in FacetedSolrSearchProvider:

    private static final String ADDITIONAL_FILTERS = "additionalFilters";
Generated at Mon Feb 12 10:59:53 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.