# Compute result facets `POST /discovery/v1/facets` Compute facets from a structured JSON request body. ## Request example ```bash curl --request POST \ --url 'https://api.eu1.luigisbox.ai/discovery/v1/facets?channel_id=' \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "debug": false, "facets": [ { "field": "example", "size": 1 } ], "guid": "example", "hierarchy_anchors": [ { "field": "example", "path": "example" } ], "hierarchy_depths": [ { "depth": 1, "field": "example" } ] }' ``` ## Query Parameters | Name | Type | Required | Description | Constraints | |---|---|---|---|---| | `channel_id` | `string` | Yes | Channel identifier (serving destination). | >= 1 characters | ## Request Body **Required.** ### application/json Schema: `object` #### Attributes | Attribute | Type | Required | Description | Constraints | |---|---|---|---|---| | `debug` | `boolean` | No | Include a diagnostic debug payload in the response. | — | | `facets` | `Array` | Yes | Fields to compute facets for, each with an optional size cap on returned values. | >= 1 items; <= 100 items | | `facets[].field` | `string` | Yes | Field to compute facet values for. | >= 1 characters | | `facets[].size` | `anyOf(integer, null)` | No | Maximum number of values returned for a keyword facet; omit for the server default. | — | | `guid` | `string` | Yes | Result-set identifier from a prior search or collections response. | >= 1 characters; <= 64 characters | | `hierarchy_anchors` | `Array` | No | Explicitly opened branches whose children should be expanded in a hierarchy facet. | <= 50 items | | `hierarchy_anchors[].field` | `string` | Yes | Hierarchical facet field the anchor applies to. | >= 1 characters | | `hierarchy_anchors[].path` | `string` | Yes | Node path whose children to expand, as the ' > '-joined string stored in the field. | >= 1 characters; <= 1024 characters | | `hierarchy_depths` | `Array` | No | Per-field child-level expansion depth for hierarchy facets; each field may appear at most once. | <= 50 items | | `hierarchy_depths[].depth` | `integer` | Yes | Number of child levels to expand from the roots. | >= 1; <= 5 | | `hierarchy_depths[].field` | `string` | Yes | Hierarchical facet field the depth applies to. | >= 1 characters | #### Request body example ```json { "debug": false, "facets": [ { "field": "example", "size": 1 } ], "guid": "example", "hierarchy_anchors": [ { "field": "example", "path": "example" } ], "hierarchy_depths": [ { "depth": 1, "field": "example" } ] } ``` ## Responses | Status | Description | Content | |---|---|---| | `200` | Successful Response | application/json: object | | `400` | Malformed request | application/json: object | | `401` | Missing or invalid credentials | application/json: object | | `403` | Authenticated but not permitted | application/json: object | | `404` | Resource not found | application/json: object | | `422` | Request validation failed | application/json: object | | `429` | Rate limit exceeded | application/json: object | | `502` | Upstream service failed | application/json: object | ### 200 Successful Response #### application/json Schema: `object` ##### Attributes | Attribute | Type | Required | Description | Constraints | |---|---|---|---|---| | `debug` | `anyOf(object, null)` | No | Ranking diagnostics — an open object whose contents carry no compatibility guarantee. Populated only when the caller passed ``debug=true`` AND holds the ``discovery:debug`` permission. Omitted from the response otherwise. | — | | `debug.*` | `any` | No | Additional property. | — | | `facets` | `object` | Yes | Per-field facet aggregation results. Values, bounds and counts cover only the objects this channel can serve. | — | | `facets.*` | `anyOf(object, object, object)` | No | Additional property. | — | | `facets.*.field` | `string` | Yes | The faceted field name. | — | | `facets.*.type` | `string` | No | Type | allowed value: terms | | `facets.*.values` | `Array` | No | Values | — | | `facets.*.max` | `number` | Yes | Maximum value in the result set. | — | | `facets.*.min` | `number` | Yes | Minimum value in the result set. | — | | `facets.*.values[].children` | `Array` | No | Child nodes populated along an open branch. | — | | `facets.*.values[].has_children` | `boolean` | Yes | Whether the node has expandable descendants. | — | | `facets.*.values[].title` | `string` | Yes | Display title of the node's own identity. | — | | `facets.*.values[].value` | `string` | Yes | Fully expanded node path (segments joined by ' > '). | — | | `guid` | `string` | Yes | GUID identifying this result set. | — | ##### Response example ```json { "debug": {}, "facets": { "additionalProperty": { "field": "example", "type": "terms", "values": [ "example" ] } }, "guid": "example" } ``` ### 400 Malformed request #### application/json Schema: `object` ##### Attributes | Attribute | Type | Required | Description | Constraints | |---|---|---|---|---| | `exception_details` | `object` | No | Machine-readable error context; empty object when there is nothing to add. | — | | `exception_details.validation_errors` | `anyOf(Array, null)` | No | Every field-level problem found in the request, when validation is what failed. Absent when the rejection is not about a specific value. | — | | `exception_details.validation_errors[].loc` | `Array` | Yes | Path to the offending value from the request root, e.g. `["body", "filters", 0, "operator"]`. | — | | `exception_details.validation_errors[].msg` | `string` | Yes | What is wrong with the value at `loc`. | — | | `exception_details.validation_errors[].type` | `string` | Yes | Stable machine code for the problem, e.g. `missing` or `string_too_short`. | — | | `exception_details.*` | `any` | No | Additional property. | — | | `reason` | `string` | Yes | Human-readable, actionable error message. | — | | `request_id` | `anyOf(string, null)` | No | Request correlation ID (matches the X-Request-Id response header). | — | ##### Response example ```json { "exception_details": { "validation_errors": [ { "loc": [ "example" ], "msg": "example", "type": "example" } ] }, "reason": "example", "request_id": "example" } ``` ### 401 Missing or invalid credentials #### application/json Schema: `object` ##### Attributes | Attribute | Type | Required | Description | Constraints | |---|---|---|---|---| | `exception_details` | `object` | No | Machine-readable error context; empty object when there is nothing to add. | — | | `exception_details.validation_errors` | `anyOf(Array, null)` | No | Every field-level problem found in the request, when validation is what failed. Absent when the rejection is not about a specific value. | — | | `exception_details.validation_errors[].loc` | `Array` | Yes | Path to the offending value from the request root, e.g. `["body", "filters", 0, "operator"]`. | — | | `exception_details.validation_errors[].msg` | `string` | Yes | What is wrong with the value at `loc`. | — | | `exception_details.validation_errors[].type` | `string` | Yes | Stable machine code for the problem, e.g. `missing` or `string_too_short`. | — | | `exception_details.*` | `any` | No | Additional property. | — | | `reason` | `string` | Yes | Human-readable, actionable error message. | — | | `request_id` | `anyOf(string, null)` | No | Request correlation ID (matches the X-Request-Id response header). | — | ##### Response example ```json { "exception_details": { "validation_errors": [ { "loc": [ "example" ], "msg": "example", "type": "example" } ] }, "reason": "example", "request_id": "example" } ``` ### 403 Authenticated but not permitted #### application/json Schema: `object` ##### Attributes | Attribute | Type | Required | Description | Constraints | |---|---|---|---|---| | `exception_details` | `object` | No | Machine-readable error context; empty object when there is nothing to add. | — | | `exception_details.validation_errors` | `anyOf(Array, null)` | No | Every field-level problem found in the request, when validation is what failed. Absent when the rejection is not about a specific value. | — | | `exception_details.validation_errors[].loc` | `Array` | Yes | Path to the offending value from the request root, e.g. `["body", "filters", 0, "operator"]`. | — | | `exception_details.validation_errors[].msg` | `string` | Yes | What is wrong with the value at `loc`. | — | | `exception_details.validation_errors[].type` | `string` | Yes | Stable machine code for the problem, e.g. `missing` or `string_too_short`. | — | | `exception_details.*` | `any` | No | Additional property. | — | | `reason` | `string` | Yes | Human-readable, actionable error message. | — | | `request_id` | `anyOf(string, null)` | No | Request correlation ID (matches the X-Request-Id response header). | — | ##### Response example ```json { "exception_details": { "validation_errors": [ { "loc": [ "example" ], "msg": "example", "type": "example" } ] }, "reason": "example", "request_id": "example" } ``` ### 404 Resource not found #### application/json Schema: `object` ##### Attributes | Attribute | Type | Required | Description | Constraints | |---|---|---|---|---| | `exception_details` | `object` | No | Machine-readable error context; empty object when there is nothing to add. | — | | `exception_details.validation_errors` | `anyOf(Array, null)` | No | Every field-level problem found in the request, when validation is what failed. Absent when the rejection is not about a specific value. | — | | `exception_details.validation_errors[].loc` | `Array` | Yes | Path to the offending value from the request root, e.g. `["body", "filters", 0, "operator"]`. | — | | `exception_details.validation_errors[].msg` | `string` | Yes | What is wrong with the value at `loc`. | — | | `exception_details.validation_errors[].type` | `string` | Yes | Stable machine code for the problem, e.g. `missing` or `string_too_short`. | — | | `exception_details.*` | `any` | No | Additional property. | — | | `reason` | `string` | Yes | Human-readable, actionable error message. | — | | `request_id` | `anyOf(string, null)` | No | Request correlation ID (matches the X-Request-Id response header). | — | ##### Response example ```json { "exception_details": { "validation_errors": [ { "loc": [ "example" ], "msg": "example", "type": "example" } ] }, "reason": "example", "request_id": "example" } ``` ### 422 Request validation failed #### application/json Schema: `object` ##### Attributes | Attribute | Type | Required | Description | Constraints | |---|---|---|---|---| | `exception_details` | `object` | No | Machine-readable error context; empty object when there is nothing to add. | — | | `exception_details.validation_errors` | `anyOf(Array, null)` | No | Every field-level problem found in the request, when validation is what failed. Absent when the rejection is not about a specific value. | — | | `exception_details.validation_errors[].loc` | `Array` | Yes | Path to the offending value from the request root, e.g. `["body", "filters", 0, "operator"]`. | — | | `exception_details.validation_errors[].msg` | `string` | Yes | What is wrong with the value at `loc`. | — | | `exception_details.validation_errors[].type` | `string` | Yes | Stable machine code for the problem, e.g. `missing` or `string_too_short`. | — | | `exception_details.*` | `any` | No | Additional property. | — | | `reason` | `string` | Yes | Human-readable, actionable error message. | — | | `request_id` | `anyOf(string, null)` | No | Request correlation ID (matches the X-Request-Id response header). | — | ##### Response example ```json { "exception_details": { "validation_errors": [ { "loc": [ "example" ], "msg": "example", "type": "example" } ] }, "reason": "example", "request_id": "example" } ``` ### 429 Rate limit exceeded #### application/json Schema: `object` ##### Attributes | Attribute | Type | Required | Description | Constraints | |---|---|---|---|---| | `exception_details` | `object` | No | Machine-readable error context; empty object when there is nothing to add. | — | | `exception_details.validation_errors` | `anyOf(Array, null)` | No | Every field-level problem found in the request, when validation is what failed. Absent when the rejection is not about a specific value. | — | | `exception_details.validation_errors[].loc` | `Array` | Yes | Path to the offending value from the request root, e.g. `["body", "filters", 0, "operator"]`. | — | | `exception_details.validation_errors[].msg` | `string` | Yes | What is wrong with the value at `loc`. | — | | `exception_details.validation_errors[].type` | `string` | Yes | Stable machine code for the problem, e.g. `missing` or `string_too_short`. | — | | `exception_details.*` | `any` | No | Additional property. | — | | `reason` | `string` | Yes | Human-readable, actionable error message. | — | | `request_id` | `anyOf(string, null)` | No | Request correlation ID (matches the X-Request-Id response header). | — | ##### Response example ```json { "exception_details": { "validation_errors": [ { "loc": [ "example" ], "msg": "example", "type": "example" } ] }, "reason": "example", "request_id": "example" } ``` ### 502 Upstream service failed #### application/json Schema: `object` ##### Attributes | Attribute | Type | Required | Description | Constraints | |---|---|---|---|---| | `exception_details` | `object` | No | Machine-readable error context; empty object when there is nothing to add. | — | | `exception_details.validation_errors` | `anyOf(Array, null)` | No | Every field-level problem found in the request, when validation is what failed. Absent when the rejection is not about a specific value. | — | | `exception_details.validation_errors[].loc` | `Array` | Yes | Path to the offending value from the request root, e.g. `["body", "filters", 0, "operator"]`. | — | | `exception_details.validation_errors[].msg` | `string` | Yes | What is wrong with the value at `loc`. | — | | `exception_details.validation_errors[].type` | `string` | Yes | Stable machine code for the problem, e.g. `missing` or `string_too_short`. | — | | `exception_details.*` | `any` | No | Additional property. | — | | `reason` | `string` | Yes | Human-readable, actionable error message. | — | | `request_id` | `anyOf(string, null)` | No | Request correlation ID (matches the X-Request-Id response header). | — | ##### Response example ```json { "exception_details": { "validation_errors": [ { "loc": [ "example" ], "msg": "example", "type": "example" } ] }, "reason": "example", "request_id": "example" } ```