# Google Cloud Retail V2 Client - Class CustomAttribute (2.5.3)

2.5.3 (latest) 2.5.2 2.4.0 2.3.1 2.2.1 2.1.3 2.0.0 1.7.0 1.6.4 1.5.0 1.4.2 1.3.1 1.2.1 1.1.1 1.0.1 Reference documentation and code samples for the Google Cloud Retail V2 Client class CustomAttribute.

A custom attribute that is not explicitly modeled in
[Product](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Product).

Generated from protobuf message `google.cloud.retail.v2.CustomAttribute`

## Namespace

Google \\ Cloud \\ Retail \\ V2

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ text` | `string[]` The textual values of this custom attribute. For example, `["yellow", "green"]` when the key is "color". Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is returned. Exactly one of [text](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getText__) or [numbers](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getNumbers__) should be set. Otherwise, an INVALID_ARGUMENT error is returned. |
| `↳ numbers` | `float[]` The numerical values of this custom attribute. For example, `[2.3, 15.4]` when the key is "lengths_cm". Exactly one of [text](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getText__) or [numbers](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getNumbers__) should be set. Otherwise, an INVALID_ARGUMENT error is returned. |
| `↳ searchable` | `bool` This field is normally ignored unless [AttributesConfig.attribute_config_level](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.AttributesConfig#_Google_Cloud_Retail_V2_AttributesConfig__getAttributeConfigLevel__) of the [Catalog](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Catalog) is set to the deprecated 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level attribute configuration, see [Configuration modes](https://cloud.google.com/retail/docs/attribute-config#config-modes). If true, custom attribute values are searchable by text queries in [SearchService.Search](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Client.SearchServiceClient#_Google_Cloud_Retail_V2_Client_SearchServiceClient__search__). This field is ignored in a [UserEvent](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.UserEvent). Only set if type [text](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getText__) is set. Otherwise, a INVALID_ARGUMENT error is returned. |
| `↳ indexable` | `bool` This field is normally ignored unless [AttributesConfig.attribute_config_level](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.AttributesConfig#_Google_Cloud_Retail_V2_AttributesConfig__getAttributeConfigLevel__) of the [Catalog](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Catalog) is set to the deprecated 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level attribute configuration, see [Configuration modes](https://cloud.google.com/retail/docs/attribute-config#config-modes). If true, custom attribute values are indexed, so that they can be filtered, faceted or boosted in [SearchService.Search](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Client.SearchServiceClient#_Google_Cloud_Retail_V2_Client_SearchServiceClient__search__). This field is ignored in a [UserEvent](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.UserEvent). See [SearchRequest.filter](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.SearchRequest#_Google_Cloud_Retail_V2_SearchRequest__getFilter__), [SearchRequest.facet_specs](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.SearchRequest#_Google_Cloud_Retail_V2_SearchRequest__getFacetSpecs__) and [SearchRequest.boost_spec](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.SearchRequest#_Google_Cloud_Retail_V2_SearchRequest__getBoostSpec__) for more details. |

### getText

The textual values of this custom attribute. For example, `["yellow",
"green"]` when the key is "color".

Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is
returned.
Exactly one of [text](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getText__) or
[numbers](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getNumbers__) should be set.
Otherwise, an INVALID_ARGUMENT error is returned.

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

### setText

The textual values of this custom attribute. For example, `["yellow",
"green"]` when the key is "color".

Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is
returned.
Exactly one of [text](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getText__) or
[numbers](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getNumbers__) should be set.
Otherwise, an INVALID_ARGUMENT error is returned.

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

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

### getNumbers

The numerical values of this custom attribute. For example, `[2.3, 15.4]`
when the key is "lengths_cm".

Exactly one of [text](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getText__) or
[numbers](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getNumbers__) should be set.
Otherwise, an INVALID_ARGUMENT error is returned.

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

### setNumbers

The numerical values of this custom attribute. For example, `[2.3, 15.4]`
when the key is "lengths_cm".

Exactly one of [text](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getText__) or
[numbers](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getNumbers__) should be set.
Otherwise, an INVALID_ARGUMENT error is returned.

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

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

### getSearchable

This field is normally ignored unless
[AttributesConfig.attribute_config_level](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.AttributesConfig#_Google_Cloud_Retail_V2_AttributesConfig__getAttributeConfigLevel__)
of the [Catalog](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Catalog) is set to the deprecated
'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level
attribute configuration, see [Configuration
modes](https://cloud.google.com/retail/docs/attribute-config#config-modes).

If true, custom attribute values are searchable by text queries in
[SearchService.Search](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Client.SearchServiceClient#_Google_Cloud_Retail_V2_Client_SearchServiceClient__search__).
This field is ignored in a [UserEvent](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.UserEvent).
Only set if type [text](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getText__) is
set. Otherwise, a INVALID_ARGUMENT error is returned.

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

### hasSearchable

### clearSearchable

### setSearchable

This field is normally ignored unless
[AttributesConfig.attribute_config_level](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.AttributesConfig#_Google_Cloud_Retail_V2_AttributesConfig__getAttributeConfigLevel__)
of the [Catalog](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Catalog) is set to the deprecated
'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level
attribute configuration, see [Configuration
modes](https://cloud.google.com/retail/docs/attribute-config#config-modes).

If true, custom attribute values are searchable by text queries in
[SearchService.Search](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Client.SearchServiceClient#_Google_Cloud_Retail_V2_Client_SearchServiceClient__search__).
This field is ignored in a [UserEvent](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.UserEvent).
Only set if type [text](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.CustomAttribute#_Google_Cloud_Retail_V2_CustomAttribute__getText__) is
set. Otherwise, a INVALID_ARGUMENT error is returned.

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

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

### getIndexable

This field is normally ignored unless
[AttributesConfig.attribute_config_level](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.AttributesConfig#_Google_Cloud_Retail_V2_AttributesConfig__getAttributeConfigLevel__)
of the [Catalog](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Catalog) is set to the deprecated
'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level
attribute configuration, see [Configuration
modes](https://cloud.google.com/retail/docs/attribute-config#config-modes).

If true, custom attribute values are indexed, so that they can be filtered,
faceted or boosted in
[SearchService.Search](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Client.SearchServiceClient#_Google_Cloud_Retail_V2_Client_SearchServiceClient__search__).
This field is ignored in a [UserEvent](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.UserEvent).
See [SearchRequest.filter](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.SearchRequest#_Google_Cloud_Retail_V2_SearchRequest__getFilter__),
[SearchRequest.facet_specs](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.SearchRequest#_Google_Cloud_Retail_V2_SearchRequest__getFacetSpecs__)
and
[SearchRequest.boost_spec](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.SearchRequest#_Google_Cloud_Retail_V2_SearchRequest__getBoostSpec__)
for more details.

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

### hasIndexable

### clearIndexable

### setIndexable

This field is normally ignored unless
[AttributesConfig.attribute_config_level](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.AttributesConfig#_Google_Cloud_Retail_V2_AttributesConfig__getAttributeConfigLevel__)
of the [Catalog](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Catalog) is set to the deprecated
'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level
attribute configuration, see [Configuration
modes](https://cloud.google.com/retail/docs/attribute-config#config-modes).

If true, custom attribute values are indexed, so that they can be filtered,
faceted or boosted in
[SearchService.Search](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Client.SearchServiceClient#_Google_Cloud_Retail_V2_Client_SearchServiceClient__search__).
This field is ignored in a [UserEvent](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.UserEvent).
See [SearchRequest.filter](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.SearchRequest#_Google_Cloud_Retail_V2_SearchRequest__getFilter__),
[SearchRequest.facet_specs](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.SearchRequest#_Google_Cloud_Retail_V2_SearchRequest__getFacetSpecs__)
and
[SearchRequest.boost_spec](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.SearchRequest#_Google_Cloud_Retail_V2_SearchRequest__getBoostSpec__)
for more details.

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

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