Configure hierarchical facets
Hierarchical facets are a type of facet that allows Constructor to format a facet response in a nested/hierarchical format.
Create a facet and set it as type hierarchical
.
Each facet option needs to have a facet options configuration indicating its parent_value
under its data
field as JSON.
- Facet option syntax
[parent facet option][delimiter][facet option]
.- Valid delimiters
-
,/
- Example:
mens/us/10
- Valid delimiters
- Root facet options will have
"parent_value": null
.
// root example
{
"value": "mens",
"data": { "parent_value": null }
}
// leaf example
{
"value": "mens/us/10",
"data": { "parent_value": "us" }
}
Applying these facets options to an item requires the item to have each individual facet value facet:size
-> mens|mens/us|mens/us/10|mens/us/11
.
Example response
{
"display_name": "Shoe Size",
"name": "size",
"type": "hierarchical",
"options": [
{
"status": "",
"count": 422,
"display_name": "Mens",
"value": "mens",
"data": {
"parent_value": null
},
"options": [
{
"status": "",
"count": 422,
"display_name": "US",
"value": "mens/us",
"data": {
"parent_value": "mens"
},
"options": [
{
"status": "",
"count": 416,
"display_name": "10",
"value": "mens/us/10",
"data": {
"parent_value": "mens/us"
},
"options": []
},
{
"status": "",
"count": 6,
"display_name": "11",
"value": "mens/us/11",
"data": {
"parent_value": "mens/us"
},
"options": []
}
]
}
]
}
],
"hidden": false,
"data": {}
}
Updated 13 days ago