- Issue created by @aaronpinero
I would like to be able to sort search results by two fields. In my case, sorting by date (descending) and by title (ascending). Currently, the configuration options for an endpoint allow only one sorting field and one sorting order. Also, I have examined the prepareQuery function in the SearchApiEndpointController and it does not appear possible to provide a query parameter with the endpoint url indicating more than one sort field (like "&sort=date,title").
As a test, I added a hard-coded secondary sort in prepareQuery function (right below the existing sort declaration on line 225 of SearchApiEndpointController):
<pre>$query->sort($sort, $order); // existing line of code
$query->sort('title', 'asc');</pre>
This had the desired effect. My search results were sorted both by the default sort (date) and then the additional sort (title).
My suggestion is twofold:
These changes might necessitate additional modifications elsewhere.
I'm not sure if there are data model changes. It might be necessary to store the default sort and order values in a different way so as to maintain the sort/order pairs.
Active
1.0
Endpoint