You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Kiran Jayakumar <ki...@gmail.com> on 2012/08/23 02:49:58 UTC

Querying top n of each facet value

Hi everyone,

I am building an auto complete feature, which facets by a field called
"Category". I want to return a minimum number of documents per facet (say
min=1 & max=5).

The facet output is something like

Category
A: 500
B: 10
C: 2

By default, it is returning 10 documents of category A.

I want it to return a total of 10 documents, with 1 document atleast for
each facet value. Is it possible to accomplish that with a single query ?

Thanks

Re: Querying top n of each facet value

Posted by Kiran Jayakumar <ki...@gmail.com>.
Thank you Tanguy. This seems to work:

group = true
group.field = Category
group.limit = 5

http://wiki.apache.org/solr/FieldCollapsing

group.limit

[number]

The number of results (documents) to return for each group. Defaults to 1.

On Thu, Aug 23, 2012 at 1:33 AM, Tanguy Moal <ta...@gmail.com> wrote:

> Hello Kiran,
>
> I think you can try turning grouping on and group "on", and ask solr to
> group on the "Category" field.
>
> Nevertheless, this will *not* ensure you that groups are returned in facet
> counts order. This will *not* ensure you the mincount per group neither.
>
> Hope this helps,
>
> --
> Tanguy
>
> 2012/8/23 Kiran Jayakumar <ki...@gmail.com>
>
> > Hi everyone,
> >
> > I am building an auto complete feature, which facets by a field called
> > "Category". I want to return a minimum number of documents per facet (say
> > min=1 & max=5).
> >
> > The facet output is something like
> >
> > Category
> > A: 500
> > B: 10
> > C: 2
> >
> > By default, it is returning 10 documents of category A.
> >
> > I want it to return a total of 10 documents, with 1 document atleast for
> > each facet value. Is it possible to accomplish that with a single query ?
> >
> > Thanks
> >
>

Re: Querying top n of each facet value

Posted by Tanguy Moal <ta...@gmail.com>.
Hello Kiran,

I think you can try turning grouping on and group "on", and ask solr to
group on the "Category" field.

Nevertheless, this will *not* ensure you that groups are returned in facet
counts order. This will *not* ensure you the mincount per group neither.

Hope this helps,

--
Tanguy

2012/8/23 Kiran Jayakumar <ki...@gmail.com>

> Hi everyone,
>
> I am building an auto complete feature, which facets by a field called
> "Category". I want to return a minimum number of documents per facet (say
> min=1 & max=5).
>
> The facet output is something like
>
> Category
> A: 500
> B: 10
> C: 2
>
> By default, it is returning 10 documents of category A.
>
> I want it to return a total of 10 documents, with 1 document atleast for
> each facet value. Is it possible to accomplish that with a single query ?
>
> Thanks
>