Closed (fixed)
Project:
Facet API
Version:
7.x-1.x-dev
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
12 Feb 2013 at 14:10 UTC
Updated:
15 Apr 2013 at 18:20 UTC
Hi,
(How) can I create hierarchical facets?
Cheers,
Dan.
Comments
Comment #1
cpliakas commentedThis depends largely on the backend and the field you are working with.
Definitely need more information,
Chris
Comment #2
dbolser commentedI'm using Apache Solr, and I can use any field.
I'm not currently indexing Drupal content, but rather pointing Apache Solr at an 'external' index (that I'm free to create however I want). I have 'tags' like taxonomy terms, but I'm not sure how to hook it all into the search page.
For simplicity, I could just 'vanilla' Apache Solr over Drupal content (tagged with terms from a taxonomy) to just get going with hierarchical facets.
Many thanks,
Dan.
Comment #3
cpliakas commentedHi Dan.
Thanks for the details.
So the short answer is that if the field had data indexed in a hierarchical manner, i.e. it is a multi-valued field that indexes the item and it's parents, you are half way there. The next thing you have to do is implement hook_factapi_facet_info() to define the facet, paying special attention to the "hierarchy callback" key. This allows you to to define a callback that maps the parents and children.
For some examples, check out the facetapi_facetapi_facet_info() function for defining facets and facetapi_get_taxonomy_hierarchy() for building the hierarchy callback.
Hope this helps,
Chris
Comment #4
cpliakas commented