Here is some detail about how grouping is implemented in Solr.
http://fulmicoton.com/posts/grouping-in-solr/



On Mon, Aug 5, 2013 at 2:42 AM, Tony Paloma <to...@valvesoftware.com> wrote:

> Thanks Paul. That's helpful. I'm not familiar with the concept of custom
> caches. Would this be custom Java code or something defined in the
> config/schema? Can you point me to some documentation?
>
> Another workaround I was thinking of using was making two Solr queries
> when wanting to sort groups by price desc. One to get the number of total
> groups and then another that gets groups sorted by price asc starting from
> ngroups - (start+rows) and then just flip the ordering to fake sorting by
> min(price) desc, but I was worried about the performance implications of
> that.
>
> SOLR-2072 has a similar request.
> https://issues.apache.org/jira/browse/SOLR-2072
>
> Bryan's comment is exactly what I'm looking for:
> > I would like to able to use sort and group.sort together such that the
> group.sort is applied with in the group first and the first document of
> each group is then used as the representative document to perform the
> overall sorting of groups.
>
> The latest comment there suggests that it's a bug in distributed mode, but
> I don't think that's the case since I'm only using one instance of Solr
> with no sharding or anything.
>
> -----Original Message-----
> From: Paul Masurel [mailto:paul.masu...@gmail.com]
> Sent: Sunday, August 04, 2013 2:54 PM
> To: solr-user@lucene.apache.org
> Subject: Re: Unexpected behavior when sorting groups
>
> Dear Tony,
>
> The behavior you described is correct, and what you are requiring is
> impossible with Solr as it is.
>
> I wouldn't however say it is a limitation of Solr : your problem is
> actually difficult and require some preprocessing.
>
> One solution if it is feasible for you is to precompute the lowest price
> of your groups beforehands and add a field to all of the document of your
> group.
>
> The other way to address your problem is to do that within Solr.
> This can be done by adding a custom cache holding these values.
> You can implement the computation of the min price in the warm method.
>
> You can then add a custom function to return the result stored in this
> cache. Function values can be used for sorting.
>
> If if does not exist yet, you may open a ticket. I will try and get
> authorization to opensource a solution for this.
>
> Regards,
>
> Paul
>
>
>
>
> On Sat, Aug 3, 2013 at 12:00 AM, Tony Paloma <to...@valvesoftware.com
> >wrote:
>
> > I'm using field collapsing to group documents by a single field and
> > have run into something unexpected with how sorting of the groups
> > works. Right now I have each group return one document. The documents
> > within each group are sorted by a field ("price") in ascending order
> > using group.sort so that the document returned for each group in the
> > search results is the cheapest document of the group. If I sort the
> > groups amongst themselves using sort=price asc, I get what I expect
> > with groups having documents whose lowest price value is low show
> > first and groups having documents whose lowest price value is high show
> last.
> >
> > If I change this to sort on price desc, what happens is not what I
> > would expect. I would like the groups to be returned in reverse order
> > from what happened when sorting by price asc. Instead, what happens is
> > the groups are sorted in descending order according to the highest
> > priced document in each group. I want groups to be sorted in
> > descending order according to the lowest priced document in each group,
> but it appears this is not possible.
> > In other words, it appears sorting when groups are involved is limited
> > to either MAX([field]) DESC or MIN([field]) ASC. The other two
> > combinations are not possible. Does anyone know whether or not this is
> > in fact impossible, and if not, how I might put in a feature request?
> >
>
>
>
> --
> ______________________________________________
>
>  Masurel Paul
>  e-mail: paul.masu...@gmail.com
>



-- 
______________________________________________

 Masurel Paul
 e-mail: paul.masu...@gmail.com

Reply via email to