: > such that if you search for category, you get all those documents that have
: > been tagged with the category AND any sub categories. If this is possible I
: > think I'll investigate using solr in place of some existing code we have
: > that deals with indexing and searching of such data.
:
: sort of. you can index a field literally as "category/subcategory/
: subsubcategory" and query for category/* to get all documents in that category
: and below.
I deal with this kind of stuff all the time ... if you can model your
hierarchy using unique categoryIds (numbers are easiest) such that no
categoryId appears more then one place in the hierarchy (something that
frequently isn't possible with "category names" then it's really easy to
just index the entire "breadcrumb" for a document and then you can search
on any categoryId and get all of the documents in any "descendent"
category.
ie, if this is your hierarchy...
Products/
Products/Computers/
Products/Computers/Laptops
Products/Computers/Desktops
Products/Cases
Products/Cases/Laptops
Products/Cases/CellPhones
Then this trick won't work (because Laptops appears twice) but if you have
numeric IDs that corrispond with each of those categories (so that the two
instances of Laptops are unique...
1/
1/2/
1/2/3
1/2/4
1/5/
1/5/6
1/5/7
...then you just index the full "path" (a pattern tokenizer can work fine)
and then you can search on "5" and get all products which are "Cases")
-Hoss