Closed (fixed)
Project:
Apache Solr Search
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
16 Dec 2009 at 03:59 UTC
Updated:
18 Mar 2015 at 11:20 UTC
Jump to comment: Most recent
Comments
Comment #1
pwolanin commentedcurrent code does not support multiple sorts - the sort string parsing would need to be fixed up
Comment #2
agileware commentedThat's what I expected.
I have approached this multi-domain search requirement a different way now anyway.
Instead I add radio buttons to the search forms for searching all domains or a specific one. Then I just use the default score sort.
Not exactly the same result but works well. Probably even more user friendly.
Multiple sort fields would be a useful addition though at some point.
Comment #3
jcfiala commentedI have faked out the sort to allow multiple sort fields like this:
1) I create my own custom override of the Solr_Base_Query.php class. It inherits from Solr_Base_Query, and it's defined in the custom module's install:
2) In the Example_Custom_Solr_Query object, I muck with the values it returns from get_solrsort, like so:
In this case, I'm sorting on the #name and #direction fed to apachesolr_search_execute, but I return a little extra to the direction. I've found that the function that calls get_solrsort() doesn't care what's in these fields or validate them in any way, it just puts them together with a space between them and sends them to the solr engine.
It's a hack, but it works.
(NB: Solr doesn't seem to like spaces around the commas separating the items you're sorting on.)
Comment #4
pwolanin commentedComment #5
pwolanin commentedComment #6
wouters_f commentedMaybe It could be usefull to get soem of the best sort solutions in the apachesolr_sort module.
I already added some functionalities here:
http://drupal.org/sandbox/wouters_frederik/1124756
Comment #7
pwolanin commentedThe recent changes in 7.x to the query class should bring it much closer to handling multiple sorts
Basically, omeone just needs to go and make it handle multiple solrsort[]= params instead of a single string and handle merging too/from the internal params.
Comment #8
agileware commentedThe solution in #3 worked for me in D6, thanks for the idea.
Comment #9
ryandekker commentedThis will get broken by subsequent calls to setSolrsort(), but it does work to get multiple sorts working in 7.x-1.x. It is still a bit clunky, in that
$query->sortstringremains blank.Comment #10
nick_vhFields that are set multiple now get indexed as a single to support the sorting functionality. Marking as fixed until reopened
Comment #11
nick_vhComment #12
Anonymous (not verified) commentedIs there a possibility yet to achieve anything like in #9 (sending something like this to Solr:
sort_title asc,score desc) ? Or could someone explain #10 in more detail?