Skip to main content
$facet builds a hierarchical bucket tree from FACET field paths. Use it for category navigation and drill-down style faceting.

Compatibility

Field TypeSupported
TEXTNo
U64/I64/F64No
DATENo
BOOLNo
KEYWORDNo
FACETYes

Arguments

ArgumentTypeRequiredDescription
fieldstringYesFACET field name.
pathstringYesRoot path to expand. Must start with /.
depthnumberNoLevels to traverse (>= 1). Default: 1.
sizenumberNoMax children per level. Default: 10.
minDocCountnumberNoMinimum docs required for a child bucket. Default: 1.
orderobjectNoOne-key order object: { "count": "asc|desc" } or { "path": "asc|desc" }. Default: { "count": "desc" }.

Output

  • Increase depth for multi-level facet trees.
  • Use size and minDocCount to control noise and response size.
  • Use order to sort by count or by path.
With depth: 2, the response includes nested children:
  • $facet cannot contain $aggs.
  • $facet cannot be used as a sub-aggregation inside another $aggs block.