---
title: "Controlling facet types"
slug: "controlling-facet-types"
abstract: "Advanced examples that show you how to use the Discover Search and Recommendation API to control facet types."
---
# Controlling facet types

> [!note]
> See [Using faceted search](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/integrate-using-the-search-and-recommendation-api/examples-of-advanced-search-and-recommendation-use-cases/using-faceted-search.html "Using faceted search") for basic facet use cases.

To request specific facet types, you set the `all` flag to `1` and indicate the required facet type values.

The following examples continue the [getting facet values from each facet type example](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/integrate-using-the-search-and-recommendation-api/examples-of-advanced-search-and-recommendation-use-cases/using-faceted-search.html#UUID-c83dce98-05b9-df40-143c-aa7e7ffc5820_section-idm4652146060729632877707930886 "Getting facet values from each facet type").

<details>
<summary><h2>Getting only color facets</h2></summary>

In this example, you request three facet values from the `colors` facet.

Here is the request:

```JSON
{
  "facet": {
    "colors": {"max": 3}
  }
}
```

Here is the response:

```JSON
{
  "ts": 1480977544,
  "rid": "response_id_181",
  "facet": {
    "colors": {
      "value": [
        {"id": "color_id_red", "text": "Red", "count": 23},
        {"id": "color_id_blue", "text": "Blue", "count": 11},
        {"id": "color_id_yellow", "text": "Yellow", "count": 10}
      ]
    }
  },
  "facet_names": ["colors"]
}
```

</details>

<details>
<summary><h2>Getting different facet value amounts</h2></summary>

The following shows an example of getting different facet value amounts. In this example, you request five facet values for `colors` and three facets for `product_type`.

Here is the request:

```JSON
{
  "facet": {
    "colors": {
"max": 5
    },
    "product_type": {
"max": 3
    }
  }
}
```

Here is the response:

```JSON
{
  "ts": 1480977544,
  "rid": "response_id_182",
  "facet": {
    "colors": {
      "value": [
        {"id": "color_id_red", "text": "Red", "count": 23},
        {"id": "color_id_blue", "text": "Blue", "count": 11},
        {"id": "color_id_yellow", "text": "Yellow", "count": 10},
        {"id": "color_id_black", "text": "Black", "count": 8},
        {"id": "color_id_white", "text": "White", "count": 1}
      ]
    },
    "product_type": {
      "value": [
        {"id": "prod_type_id_ring", "text": "Ring", "count": 105},
        {"id": "prod_type_id_necklace", "text": "Necklace", "count": 45},
        {"id": "prod_type_id_watch", "text": "Watch", "count": 5}
      ]
    }
  },
  "facet_names": ["colors", "product_type"]
}
```

</details>