> 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
