SOLR - How to have facet counts restricted to rows returned in resultset?

Sorry, but I don't think it is possible. The facets are always based on all the documents matching the query.

I think this is the answer to my query, and it is indeed very unfortunate that this feature has not yet been implemented in SOLR. The hacks spelt out in the other question linked above are also not really worthy, on a production server with huge data. Would appreciate if the SOLR creators can implement this feature in the near future – user489895 Nov 16 '10 at 4:22.

Not a real answer but maybe better than nothing: the results grouping feature (check out from trunk! ): wiki.apache.org/solr/FieldCollapsing where facet. Field=category is then similar to group.

Field=category and you will get only as much groups ('facet hits') as you specified!

If you always execute the same query (q=*:*), maybe you can use facet. Limit, for example: select/? Q=*:*&rows=100&facet=on&facet.

Field=category&facet. Limit=100 Tell us if the order that solr uses is the same in the facet as in the query :.

To answer your question first - yes, the order is the same in the facet as in the query. However, here we cant use facet. Limit as facet.

Limit only limits the number of facets to return. It does not limit the resultset. So, select/?

Q=*:*&rows=100&facet=on&facet. Field=category&facet. Limit=100 will only return 100 category values.It will not limit the resultset to 100, as is the requirement here.

– user489895 Nov 16 '10 at 4:14.

I don't think it is possible in any direct manner, as was pointed out by Pascal. I can see two ways to achieve this: Method I: do the counting yourself visiting the 100 results returned. This is very easy and fast if they are categorical fields, but harder if they are text fields that need to be tokenized, etc.Method II: do two passes: Do a normal query without facets (you only need to request doc ids at this point) Collect all the IDs of the documents returned Do a second query for all fields and facets, adding a filter to restrict result to those IDs collected in setp 2.

Something like: select/? Q=:&facet=on&facet. Field=category&fq=id:(312 OR 28 OR 1231 ...) The first is way more efficient and I would recommend for non-textual filds.

The second is computationally expensive but has the advantage of working for all types od fields.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions