Uploaded image for project: 'Solr Search Provider'
  1. Solr Search Provider
  2. MGNLEESOLR-79

Support for multiple Solr sort fields

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Neutral
    • 3.0.1
    • 3.0
    • None

    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

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              Unassigned Unassigned
              edgar Edgar Vonk
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Checklists

                  Task DoD