mmmm another solution that jumped to my mind is to use stats : Given the field : product_id to be the collapsing field.
For the facet i want the collapsed count I can do something like : { brands:{ terms : { // terms facet creates a bucket for each indexed term in the field field : brand, sort : "uniqueProducts desc", facet : { uniqueProducts : "unique(product_id)" } } } } I will try it for curiousity! Cheers On Thu, Sep 8, 2016 at 9:45 AM, Alessandro Benedetti <abenede...@apache.org> wrote: > Hi guys, > was thinking to this problem : > > Given a set of flat documents I want to calculate facets on : > 1) flat results set > 2) collapsed result set > > Specifically some of my field facets will need to be on the flat results > set and some of them will need to be calculated over a collapsed result set > ( you can immagine collapsed on one specific field). > > I know that this ideally can be solve restructuring the index in a nested > object model and I agree that would be a good approach to address this > problem ( as the nesting structure can be useful to solve other problems as > well) > > Let's assume I don't want to change at all my schema. > Is there a way to specify for some facet a domain ( the collapse filter > query), while for others not ? > I was taking a look to this : http://yonik.com/facet-domains/ which is > conceptually similar to what I am describing but at the moment does not > support a flexible use case ( taking in input a random filter query) . > > A naive solution would be to run 2 separates Solr queries ( one collapsed > and one not). > But let's explore other ideas ! > > Cheers > > > > -- > -------------------------- > > Benedetti Alessandro > Visiting card : http://about.me/alessandro_benedetti > > "Tyger, tyger burning bright > In the forests of the night, > What immortal hand or eye > Could frame thy fearful symmetry?" > > William Blake - Songs of Experience -1794 England > -- -------------------------- Benedetti Alessandro Visiting card : http://about.me/alessandro_benedetti "Tyger, tyger burning bright In the forests of the night, What immortal hand or eye Could frame thy fearful symmetry?" William Blake - Songs of Experience -1794 England