Faceting
Count matching documents per field value, over the whole result set.
The facet search parameter takes a comma-separated list of fields declared
facet: true, and returns a value → count breakdown for each, computed over
every matching document — not just the current page:
curl 'localhost:8108/collections/products/search?q=keyboard&facet=brand'{
"found": 42,
"hits": [ "..." ],
"facets": {
"brand": { "Logitech": 12, "Razer": 8, "Corsair": 5 }
}
}Notes
- Counts are ordered most-common first.
- Each field is capped at its 100 most common values.
- Numeric and boolean values are rendered as string keys (
"2024": 3, booleans as"1"/"0"). - A multi-valued field counts a document once per distinct value it holds,
so per-value counts across a facet can sum to more than
found. - A field not declared
facet: truein the schema returns a400 invalid_queryerror if passed tofacet.