I had the chance to make some investigation code side,
and I basically confirm what Erick hypothesized and what Diego Ceccarelli
mentioned in this other thread [1].

Grouping happens with a 2 collector phases strategy :

1) first phase retrieve and sort the groups
2) second phase retrieve the top documents per group and sort them.

The phases are indipendent so the documents you retrieve in phase 2 don't
affect the order of groups ( that was estabilished in phase1 ).

Specifically to the phase 1, we keep for each group the most representative
value(s).
If the sort is by score asc for each group, the min score is stored in
values.
If the sort is by score desc, for each group the max score is stored in
values.

Then when ordering the groups, we just add them to a treeSet using the field
comparator on those values.

To conclude, when retrieving one doc per group and a flat list, this
behaviour may sound counter-intuitive.
I guess you should use the field collapsing[2] and you should see a
consistent behavior to what you expect.

Cheers

[1]
http://lucene.472066.n3.nabble.com/Question-about-grouping-in-distribute-mode-td4327679.html
[2]
https://cwiki.apache.org/confluence/display/solr/Collapse+and+Expand+Results



-----
---------------
Alessandro Benedetti
Search Consultant, R&D Software Engineer, Director
Sease Ltd. - www.sease.io
--
View this message in context: 
http://lucene.472066.n3.nabble.com/Grouped-Result-sort-issue-tp4329255p4329784.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to