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 Kashif Khan <up...@gmail.com> on 2011/12/05 12:10:29 UTC

Facet on a field with rows=n

Hi all,

i am looking for a solution where i want the facets to obtain based on the
paging of solr documents.
For ex:-

say i hv a query *:* and set start=0 and rows=10 and then i want facets on
any one of the fields in the 10 docs obtained and not on the entire docs for
which the query was matched.

Any intelligent people can solve my problem?

--
View this message in context: http://lucene.472066.n3.nabble.com/Facet-on-a-field-with-rows-n-tp3561083p3561083.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Facet on a field with rows=n

Posted by Chris Hostetter <ho...@fucit.org>.
: But there is a workaround:
: 1) Do a normal query without facets (you only need to request doc ids
: at this point)
: 2) Collect all the IDs of the documents returned
: 3) Do a second query for all fields and facets, adding a filter to
: restrict result to those IDs collected in step 2.

an easier solution, if you really just want the counts based on the data 
from th page the user is looking at, is to count up the values in your UI 
from the stored fields you get back.

(This is the type of thing that falls into the general category of "stuff 
the client can do just as easily as Solr" so there isn't really any reason
to consider implementing it in/with Solr.)


-Hoss

Re: Facet on a field with rows=n

Posted by Mark Schoy <he...@gmx.de>.
Hi Kashif,

that is not possible in solr. The facets are always based on all the
documents matching the query.

But there is a workaround:
1) Do a normal query without facets (you only need to request doc ids
at this point)
2) Collect all the IDs of the documents returned
3) Do a second query for all fields and facets, adding a filter to
restrict result to those IDs collected in step 2.

Mark

2011/12/5 Kashif Khan <up...@gmail.com>:
> Hi all,
>
> i am looking for a solution where i want the facets to obtain based on the
> paging of solr documents.
> For ex:-
>
> say i hv a query *:* and set start=0 and rows=10 and then i want facets on
> any one of the fields in the 10 docs obtained and not on the entire docs for
> which the query was matched.
>
> Any intelligent people can solve my problem?
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Facet-on-a-field-with-rows-n-tp3561083p3561083.html
> Sent from the Solr - User mailing list archive at Nabble.com.