> For the complete documentation index, see [llms.txt](https://apidocs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.akinon.com/commerce-openapis/search/introduction/facet-field-retrieval.md).

# Facet Field Retrieval

Facet fields are retrieved from Elasticsearch before product results. The retrieval process:

1. **Facet Configuration**: If a Facet Configuration exists for an attribute, it determines the facet's aggregation settings, field mappings, and extraction strategy
2. **Size Limits**:
   * If attribute key is "category\_ids", size is set to 500
   * Otherwise, default size is 100
   * Custom sizes can be configured via Facet Configuration
3. **Inventory Strategy Context**: Facet fields are returned with inventory strategy context, as prices and availability may vary by inventory strategy
4. **Widget Creation**: After retrieval, facet data is converted to widgets:
   * Attribute IDs from Elasticsearch are used to fetch attribute values from the database
   * Widget types are determined by attribute configuration
   * Widgets include choices with quantities, labels, and selection states


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://apidocs.akinon.com/commerce-openapis/search/introduction/facet-field-retrieval.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
