Hierarchical Categories β€” Facet Drill-Down Navigation

Breadcrumb-style drill-down facets from your taxonomy tree

Hierarchical Categories

Hierarchical categories enable breadcrumb-style drill-down navigation in your search sidebar: click Electronics to see sub-categories, click Computers to see Laptops. Each level narrows the results. Powered by item_list_element_N_name_sm Solr fields built automatically from your Drupal taxonomy term reference fields.

What You Get

Once configured, your search sidebar shows a collapsible drill-down facet. Visitors click any category value to zoom into that level β€” a breadcrumb trail and back button keep navigation intuitive:

Electronicsitem_list_element_1Computersitem_list_element_2Laptopsitem_list_element_3depth 1 = root Β· depth 2 = child Β· depth 3 = leaf (most specific)

How It Works

During ingestion, the module scans every entity_reference field on your node or Commerce product that points to a taxonomy_term. For each referenced term, it calls Drupal's loadAllParents() to walk the full ancestor chain, then assigns each level to a positional Solr field:

  • item_list_element_1_name_sm β€” root / top-level ancestor (depth 1)
  • item_list_element_2_name_sm β€” second level (depth 2)
  • item_list_element_3_name_sm β€” third level (depth 3)
  • … up to depth 6

You only assign a node to the most specific (leaf) term β€” the module finds all ancestors automatically. Multiple entity reference fields on the same content type are merged into the same positional fields.

No field mapping configuration needed

The item_list_element_N_name_sm fields are built automatically during real-time sync and bulk ingestion. You do not configure them in Facet Mapping β€” they appear in the Facet Configuration table automatically once content is ingested.

Step 1 β€” Build Your Taxonomy Vocabulary

Go to Structure → Taxonomy in your Drupal admin. Create a new vocabulary (e.g., "Product Categories") or use an existing one.

  1. Navigate to Structure → Taxonomy → Add vocabulary
  2. Add your root terms first (e.g., "Electronics", "Clothing", "Books")
  3. Add child terms β€” when adding a term, expand Relations and set its Parent term to the appropriate root
  4. Add leaf terms at the deepest level you need (e.g., "Laptops" under "Computers" under "Electronics")
  5. You can go up to 6 levels deep β€” deeper hierarchies are capped at depth 6

Step 2 β€” Add an Entity Reference Field to Your Content Type

Your content type needs an entity_reference field that references taxonomy terms from your vocabulary.

  1. Go to Structure → Content types → [Your type] → Manage fields
  2. Click Add field and choose Reference → Taxonomy term
  3. Under Reference type, set Vocabularies to your taxonomy (e.g., "Product Categories")
  4. Save the field settings
  5. When editing a node, assign it to the most specific (leaf) category β€” the module walks up to find all ancestors
Assign to the leaf term only

Do NOT assign a node to both "Electronics" and "Laptops" manually. Assign it to "Laptops" only β€” the module automatically adds "Electronics" (depth 1) and "Computers" (depth 2) by traversing the parent chain. Assigning to multiple levels of the same tree causes duplicate values at the root depth.

Step 3 β€” Ingest Your Content

The module picks up entity_reference β†’ taxonomy_term fields automatically during ingestion. No additional configuration is needed on the module side.

  • Real-time sync β€” enabled by default. Every time you save a node, the updated hierarchy is pushed immediately.
  • Bulk ingestion β€” go to the Data Ingestion tab and click Ingest All Now to re-process your full content library if you added the field to existing content types.

Solr Fields Produced

For a product assigned to "Laptops" (child of "Computers" → child of "Electronics"), ingestion produces:

Solr Field Value (example) Depth
item_list_element_1_name_sm Electronics 1 β€” root / top-level
item_list_element_2_name_sm Computers 2 β€” second level
item_list_element_3_name_sm Laptops 3 β€” leaf (most specific)

All fields use the _sm suffix β€” multi-valued string. If a node belongs to multiple leaf categories (e.g., "Laptops" and "Tablets"), each chain is merged: depth 2 will contain both "Laptops" and "Tablets" while depth 1 contains just "Computers".

Step 4 β€” Enable the Hierarchical Facet Widget

Once content is ingested, the item_list_element_* fields appear in your Facet Configuration table automatically.

  1. Go to the Facet Mapping tab in your Opensolr Search settings
  2. Find item_list_element_1_name_sm in the Facet Configuration section
  3. Set the Widget column to Hierarchical
  4. Set a Display Label (e.g., "Category", "Product Type")
  5. Check the Enable checkbox to show the facet on the search page
  6. Save the configuration

The search page will now show a collapsible drill-down facet. The Opensolr search engine automatically reads all item_list_element_N_name_sm fields for the selected depth. You only configure the depth-1 field β€” the rest are detected automatically.

Commerce Products

Works identically for Drupal Commerce products. The module detects entity_reference β†’ taxonomy_term fields on your product entity type. Use Structure → Commerce → Product types to add the field, then assign products to leaf category terms.

Multilingual Sites

Each language translation is ingested as a separate Solr document. Taxonomy term labels are resolved in the node's active language β€” French nodes get French category names, German nodes get German category names.

Multiple Vocabularies

You can have multiple entity reference fields pointing to different vocabularies on the same content type. All are merged into the same item_list_element_N_name_sm fields. Depth 1 may then hold values from several independent trees simultaneously.

Hierarchical facet configured?

Visit your Drupal site's /search/ page and click a top-level category in the sidebar β€” you should see the facet drill into the next level. See Facets for more on widget types and configuration options.