# Google Cloud Discovery Engine V1 Client - Class FacetKey (1.11.1)

1.11.1 (latest) 1.11.0 1.10.1 1.9.1 1.8.0 1.7.0 1.6.1 1.5.1 1.4.0 1.3.3 1.2.0 1.1.0 1.0.0 0.11.3 0.8.0 0.7.1 0.6.0 0.5.0 0.4.0 0.3.0 0.2.0 0.1.1 Reference documentation and code samples for the Google Cloud Discovery Engine V1 Client class FacetKey.

Specifies how a facet is computed.

Generated from protobuf message `google.cloud.discoveryengine.v1.SearchRequest.FacetSpec.FacetKey`

## Namespace

Google \\ Cloud \\ DiscoveryEngine \\ V1 \\ SearchRequest \\ FacetSpec

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ key` | `string` Required. Supported textual and numerical facet keys in [Document](https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.Document) object, over which the facet values are computed. Facet key is case-sensitive. |
| `↳ intervals` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.Interval>` Set only if values should be bucketed into intervals. Must be set for facets with numerical values. Must not be set for facet with text values. Maximum number of intervals is 30. |
| `↳ restricted_values` | `string[]` Only get facet for the given restricted values. Only supported on textual fields. For example, suppose "category" has three values "Action \> 2022", "Action \> 2021" and "Sci-Fi \> 2022". If set "restricted_values" to "Action \> 2022", the "category" facet only contains "Action \> 2022". Only supported on textual fields. Maximum is 10. |
| `↳ prefixes` | `string[]` Only get facet values that start with the given string prefix. For example, suppose "category" has three values "Action \> 2022", "Action \> 2021" and "Sci-Fi \> 2022". If set "prefixes" to "Action", the "category" facet only contains "Action \> 2022" and "Action \> 2021". Only supported on textual fields. Maximum is 10. |
| `↳ contains` | `string[]` Only get facet values that contain the given strings. For example, suppose "category" has three values "Action \> 2022", "Action \> 2021" and "Sci-Fi \> 2022". If set "contains" to "2022", the "category" facet only contains "Action \> 2022" and "Sci-Fi \> 2022". Only supported on textual fields. Maximum is 10. |
| `↳ case_insensitive` | `bool` True to make facet keys case insensitive when getting faceting values with prefixes or contains; false otherwise. |
| `↳ order_by` | `string` The order in which documents are returned. Allowed values are: \* \* "count desc", which means order by [SearchResponse.Facet.values.count](https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.SearchResponse.Facet.FacetValue#_Google_Cloud_DiscoveryEngine_V1_SearchResponse_Facet_FacetValue__getCount__) descending. \* \* "value desc", which means order by [SearchResponse.Facet.values.value](https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.SearchResponse.Facet.FacetValue#_Google_Cloud_DiscoveryEngine_V1_SearchResponse_Facet_FacetValue__getValue__) descending. Only applies to textual facets. If not set, textual values are sorted in [natural order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical intervals are sorted in the order given by [FacetSpec.FacetKey.intervals](https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.SearchRequest.FacetSpec.FacetKey#_Google_Cloud_DiscoveryEngine_V1_SearchRequest_FacetSpec_FacetKey__getIntervals__). |

### getKey

Required. Supported textual and numerical facet keys in
[Document](https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.Document) object, over which
the facet values are computed. Facet key is case-sensitive.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setKey

Required. Supported textual and numerical facet keys in
[Document](https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.Document) object, over which
the facet values are computed. Facet key is case-sensitive.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getIntervals

Set only if values should be bucketed into intervals. Must be set
for facets with numerical values. Must not be set for facet with text
values. Maximum number of intervals is 30.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.Interval>` |   |

### setIntervals

Set only if values should be bucketed into intervals. Must be set
for facets with numerical values. Must not be set for facet with text
values. Maximum number of intervals is 30.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.Interval>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getRestrictedValues

Only get facet for the given restricted values. Only supported on
textual fields. For example, suppose "category" has three values
"Action \> 2022", "Action \> 2021" and "Sci-Fi \> 2022". If set
"restricted_values" to "Action \> 2022", the "category" facet only
contains "Action \> 2022". Only supported on textual fields. Maximum
is 10.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<string>` |   |

### setRestrictedValues

Only get facet for the given restricted values. Only supported on
textual fields. For example, suppose "category" has three values
"Action \> 2022", "Action \> 2021" and "Sci-Fi \> 2022". If set
"restricted_values" to "Action \> 2022", the "category" facet only
contains "Action \> 2022". Only supported on textual fields. Maximum
is 10.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string[]` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getPrefixes

Only get facet values that start with the given string prefix. For
example, suppose "category" has three values "Action \> 2022",
"Action \> 2021" and "Sci-Fi \> 2022". If set "prefixes" to "Action", the
"category" facet only contains "Action \> 2022" and "Action \> 2021".

Only supported on textual fields. Maximum is 10.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<string>` |   |

### setPrefixes

Only get facet values that start with the given string prefix. For
example, suppose "category" has three values "Action \> 2022",
"Action \> 2021" and "Sci-Fi \> 2022". If set "prefixes" to "Action", the
"category" facet only contains "Action \> 2022" and "Action \> 2021".

Only supported on textual fields. Maximum is 10.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string[]` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getContains

Only get facet values that contain the given strings. For example,
suppose "category" has three values "Action \> 2022",
"Action \> 2021" and "Sci-Fi \> 2022". If set "contains" to "2022", the
"category" facet only contains "Action \> 2022" and "Sci-Fi \> 2022".

Only supported on textual fields. Maximum is 10.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<string>` |   |

### setContains

Only get facet values that contain the given strings. For example,
suppose "category" has three values "Action \> 2022",
"Action \> 2021" and "Sci-Fi \> 2022". If set "contains" to "2022", the
"category" facet only contains "Action \> 2022" and "Sci-Fi \> 2022".

Only supported on textual fields. Maximum is 10.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string[]` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getCaseInsensitive

True to make facet keys case insensitive when getting faceting
values with prefixes or contains; false otherwise.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### setCaseInsensitive

True to make facet keys case insensitive when getting faceting
values with prefixes or contains; false otherwise.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `bool` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getOrderBy

The order in which documents are returned.

Allowed values are:

- "count desc", which means order by [SearchResponse.Facet.values.count](https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.SearchResponse.Facet.FacetValue#_Google_Cloud_DiscoveryEngine_V1_SearchResponse_Facet_FacetValue__getCount__) descending.
- "value desc", which means order by [SearchResponse.Facet.values.value](https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.SearchResponse.Facet.FacetValue#_Google_Cloud_DiscoveryEngine_V1_SearchResponse_Facet_FacetValue__getValue__) descending. Only applies to textual facets. If not set, textual values are sorted in [natural
  order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical intervals are sorted in the order given by [FacetSpec.FacetKey.intervals](https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.SearchRequest.FacetSpec.FacetKey#_Google_Cloud_DiscoveryEngine_V1_SearchRequest_FacetSpec_FacetKey__getIntervals__).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setOrderBy

The order in which documents are returned.

Allowed values are:

- "count desc", which means order by [SearchResponse.Facet.values.count](https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.SearchResponse.Facet.FacetValue#_Google_Cloud_DiscoveryEngine_V1_SearchResponse_Facet_FacetValue__getCount__) descending.
- "value desc", which means order by [SearchResponse.Facet.values.value](https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.SearchResponse.Facet.FacetValue#_Google_Cloud_DiscoveryEngine_V1_SearchResponse_Facet_FacetValue__getValue__) descending. Only applies to textual facets. If not set, textual values are sorted in [natural
  order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical intervals are sorted in the order given by [FacetSpec.FacetKey.intervals](https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.SearchRequest.FacetSpec.FacetKey#_Google_Cloud_DiscoveryEngine_V1_SearchRequest_FacetSpec_FacetKey__getIntervals__).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |