: Someone always wants to understand the full use case. :-) I do 
: understand why, but, sometimes said use case is extremely complex with 
: dozens and dozens of search requirements. I was trying to limit the 
: explanation and was hoping someone could just answer the question as is. 

well -- i gave you one answer to the question as is "sort the facet.query 
counts on the client" ... my question about how you were modeling the 
taxonomy in field values is kind of crucial to any discussion about how to 
filter the facet resompse based on the taxonomy -- we have to know what 
the terms look like in order to give you suggestions on how to limit the 
temrs being faceted.

: A > B > C > D > E
: Z > C > D > E
: Z > C > F > G > H > E
: Y > G > H > E
: 
: Now, I want to get a count of the products in the children of C, AND, 
: each of their children (so, 2 levels, i.e. D, D > E, F, F > G). Note, 

Are these letters just "labels" for categories and the individual labels 
are frequently re-used to describe differnet concrete categories, or are 
you genuinely saying that a single category (labled "C") has multiple 
parent categories (B, and Z) and depending on *which* parent you are 
considering at any given time, it has differend child categories (ie: C 
has direct children D and F when viewed from parent Z, but when viewed 
from parent B, C's only direct child is D)? ... because if it's the later, 
that's the most fucked up "taxonomy" i've ever encountered.

If it's the former (just an issue of reusing labels) then you can probably 
make your life a lot simpler by choosing unique identifiers for every 
category in the hierachy (regardless o the label) and indexing those.

: The reality is products are in C. It is meaningless what parent category 
: they have, and thus what level. So, what is a good way to tackle this 
: using Solr?

from the standpoint of a single product document, you may not care what 
the "parent" categories are for each category the product, but if your 
goal is to get facet counts for every "child" category of a specified 
"parent" then it absolutely matters what the parent categories are -- the 
easiest way i know of to do that is to have a field containing each 
of the categories the document is in expressed as a "path", and then use 
facet.prefix to limit the constraints considered to terms that match the 
"path" of the parent category you are interested in.  since you also said 
you only want the categories that are immediate children of the current 
category, encoding the "level" of the category at the begining of it's 
path makes this possible using facet.prefix as well -- if you *only* ever 
want constraint counts for the immediate child categories, you can the 
level and most of the path and just index the "${parent_cat_id}:${cat_id}" 
tuples for every $cat_id the product is in, and tuples and use 
"${cat_id}:" as your facet.prefix.

-Hoss

Reply via email to