---
title: "The facet response object"
slug: "the-facet-response-object"
abstract: "Describes the structure and properties of the facet object in a Sitecore Discover Search and Recommendation response."
---
# The facet response object

You get a `facet` JSON object in the Sitecore Discover Search and Recommendation response if you send a [facet object in the request](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/search-and-recommendation-data-model/response-structure-and-objects/the-facet-request-object.md "The facet request object"). The response returns the `<facet_type>` requested and shows the corresponding facet values according to the keys in your request.

The following code shows the basic structure of the `facet` object in a response:

```csharp
{
    "facet": {
	"<facet_type>": {
        	"number_of_products": 2,
		"total": 10,
		"display_name": "<alternate_display_name>",
		"value": [{
			"id": "<facet_value_id>",
			"text": "<display_text>",
			"count": 15,
			"min": 1,
			"max": 10,
			"in_content": "<content_type>",
			"<other_fields>": "<field_value>",
			"sub": [<facet_value>]
		}]
	},
    "facet_names": [{<facet_type>}]
}
```

<details>
<summary><h2>Keys</h2></summary>

Depending on your request you might see some or all response keys.

The following table describes the keys in the `facet` response object:

| Key | Type | Description |
| --- | --- | --- |
| `facet_type` | [Facet type object](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/search-and-recommendation-data-model/response-structure-and-objects/the-facet-response-object.html#UUID-cfee8574-521d-f6f6-d659-8e78a5e1ba66_section-idm4640734247091233214095186316 "Facet type object") | Returns the `<facet_type>` sent in your request. |

### Facet type object

The following table describes the keys in the `facet_type` object:

| Key | Type | Description |
| --- | --- | --- |
| number_of_products | number | The number of products containing an attribute value with the <facet_type>. |
| total | number | Total number of facet values for the <facet_type>. |
| display_name | string | Alternate name to display the <facet_type>.You can contact your support representative if you want the response to display a different name for the returned <facet_type>. |
| id | number | A unique ID that corresponds to the facet value.You can use the id to filter future requests. |
| <other_fields> | string | The response returns the <field_value> when there is an additional field requested. |
| min | number | The minimum value in a range.The response returns this only when the <facet_type> supports a range. For example, price. |
| max | number | The maximum value in a range.The response returns this only when <facet_type> supports a range. For example, price. |
| sub | array | The response returns this only when the <facet_type> supports a nested structure such as a category tree. |
| facet_names | array | Determines the order of the returned facets. Each <facet_type> in the array corresponds to a facet returned in the response.NoteThe order of the returned facets reflects how you explicitly configured it in the Customer Engagemenrt Console (CEC). Otherwise, you get the default order. |

### Facet types

The following are default facets that come with all implementations. You can define additional facet types that are specific to your industry when you do the [initial data feed](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/search-and-recommendation-data-model/response-structure-and-objects/preparing,-uploading,-and-managing-your-data.md "Preparing, uploading, and managing your data").

| <facet_type> | Description |
| --- | --- |
| `brand` | Filter by product brands. |
| `category_names` | Filter by product category names. |
| `price` | Filter by price or price range. |
| `rating` | Filter by product review rating. You must specify a `min` and a `max`. |

</details>

<details>
<summary><h2>Examples</h2></summary>

*Example 1:* The following is an example of a response containing a term facet with discrete values. In the response, there are:

- Five *Red* items
- Two *Blue* items
- A total of eleven types of `colors`, but only two are shown

```csharp
{
    "facet": {
	"colors": {
              "number_of_products": 235,
		"total": 11,
		"value": [{
		    "id": "cr1",
		    "text": "Red",
		    "count": 5
		   },
		   {
		    "id": "cr2",
		    "text": "Blue",
		    "count": 2
		    }
	        ]
        }
    }
}
```

*Example 2:* The next example is a response containing a range facet where:

- The total number of buckets is two
- The minimum (`min`) of the price range is 10
- The maximum (`max`) of the price range is 50
- The `value` contains the suggested buckets where:
    - There are two groups of buckets
    - The first bucket is from 10 to 20
    - The second bucket is from 20 to 50

```csharp
{
    "facet": {
	"price": {
	    "number_of_products": 27,
	    "total": 2,
	    "min": 10,
	    "max": 50,
	    "value": [{
		"id": "p1",
		"text": "10 - 20",
		"count": 5,
		"min": 10,
		"max": 20
               },
	       {
		"id": "p2",
		"text": "20 - 50",
		"count": 2,
		"min": 20,
		"max": 50
	        }
	    ]
	}
    }
}
```

*Example 3:* The following is an example of a nested facet having a hierarchical structure. In this example, there are four categories:

- Mens > Shirt
- Mens > Pants
- Women > Shirt
- Women > Pants

```csharp
{
"facet": {
  "category_tree": {
    "value": [
      {
        "id": "ct1",
        "text": "Mens",
        "count": 5,
        "sub": [
          {"id": "ct11", "text": "Shirt", "count": 2},
          {"id": "ct12", "text": "Pants", "count": 3}
        ]
      },
      {
        "id": "ct2",
        "text": "Women",
        "count": 2,
        "sub": [
          {"id": "ct21", "text": "Shirt", "count": 1},
          {"id": "ct22", "text": "Pants", "count": 1}
        ]
      }
    ]
  }
}
```

</details>