# Google Cloud Retail V2 Client - Class FilterAction (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 FilterAction.

- Rule Condition:

  - No [Condition.query_terms](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Condition#_Google_Cloud_Retail_V2_Condition__getQueryTerms__) provided is a global match.
- 1 or more
  [Condition.query_terms](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Condition#_Google_Cloud_Retail_V2_Condition__getQueryTerms__)
  provided are combined with OR operator.

- Action Input: The request query and filter that are applied to the retrieved products, in addition to any filters already provided with the SearchRequest. The AND operator is used to combine the query's existing filters with the filter rule(s). NOTE: May result in 0 results when filters conflict.
- Action Result: Filters the returned objects to be ONLY those that passed the filter.

Generated from protobuf message `google.cloud.retail.v2.Rule.FilterAction`

## Namespace

Google \\ Cloud \\ Retail \\ V2 \\ Rule

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ filter` | `string` A filter to apply on the matching condition results. Supported features: \* \* [filter](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Rule.FilterAction#_Google_Cloud_Retail_V2_Rule_FilterAction__getFilter__) must be set. \* \* Filter syntax is identical to [SearchRequest.filter](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.SearchRequest#_Google_Cloud_Retail_V2_SearchRequest__getFilter__). For more information, see [Filter](https://docs.cloud.google.com/retail/docs/filter-and-order#filter). \* \* To filter products with product ID "product_1" or "product_2", and color "Red" or "Blue": *(id: ANY("product_1", "product_2"))* *AND* *(colorFamilies: ANY("Red", "Blue"))* |

### getFilter

A filter to apply on the matching condition results. Supported features:

- [filter](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Rule.FilterAction#_Google_Cloud_Retail_V2_Rule_FilterAction__getFilter__) must be set.

- Filter syntax is identical to
  [SearchRequest.filter](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.SearchRequest#_Google_Cloud_Retail_V2_SearchRequest__getFilter__). For
  more
  information, see [Filter](https://docs.cloud.google.com/retail/docs/filter-and-order#filter).

- To filter products with product ID "product_1" or "product_2", and color "Red" or "Blue":  
  *(id: ANY("product_1", "product_2"))* *AND* *(colorFamilies: ANY("Red", "Blue"))*

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

### setFilter

A filter to apply on the matching condition results. Supported features:

- [filter](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.Rule.FilterAction#_Google_Cloud_Retail_V2_Rule_FilterAction__getFilter__) must be set.

- Filter syntax is identical to
  [SearchRequest.filter](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.SearchRequest#_Google_Cloud_Retail_V2_SearchRequest__getFilter__). For
  more
  information, see [Filter](https://docs.cloud.google.com/retail/docs/filter-and-order#filter).

- To filter products with product ID "product_1" or "product_2", and color "Red" or "Blue":  
  *(id: ANY("product_1", "product_2"))* *AND* *(colorFamilies: ANY("Red", "Blue"))*

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

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