# Google Cloud Discovery Engine V1 Client - Class AnswerQueryRequest (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 AnswerQueryRequest.

Request message for
[ConversationalSearchService.AnswerQuery](https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.Client.ConversationalSearchServiceClient#_Google_Cloud_DiscoveryEngine_V1_Client_ConversationalSearchServiceClient__answerQuery__)
method.

Generated from protobuf message `google.cloud.discoveryengine.v1.AnswerQueryRequest`

## Namespace

Google \\ Cloud \\ DiscoveryEngine \\ V1

## Methods

### __construct

Constructor.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `data` | `mixed` |

### getServingConfig

Required. The resource name of the Search serving config, such as
`projects/*/locations/global/collections/default_collection/engines/*/servingConfigs/default_serving_config`,
or
`projects/*/locations/global/collections/default_collection/dataStores/*/servingConfigs/default_serving_config`.

This field is used to identify the serving configuration name, set
of models used to make the search.

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

### setServingConfig

Required. The resource name of the Search serving config, such as
`projects/*/locations/global/collections/default_collection/engines/*/servingConfigs/default_serving_config`,
or
`projects/*/locations/global/collections/default_collection/dataStores/*/servingConfigs/default_serving_config`.

This field is used to identify the serving configuration name, set
of models used to make the search.

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

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

### getQuery

Required. Current user query.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.Query|null` |   |

### hasQuery

### clearQuery

### setQuery

Required. Current user query.

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

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

### getSession

The session resource name. Not required.

When session field is not set, the API is in sessionless mode.
We support auto session mode: users can use the wildcard symbol `-` as
session ID. A new ID will be automatically generated and assigned.

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

### setSession

The session resource name. Not required.

When session field is not set, the API is in sessionless mode.
We support auto session mode: users can use the wildcard symbol `-` as
session ID. A new ID will be automatically generated and assigned.

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

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

### getSafetySpec

Model specification.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.AnswerQueryRequest.SafetySpec|null` |   |

### hasSafetySpec

### clearSafetySpec

### setSafetySpec

Model specification.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.AnswerQueryRequest.SafetySpec` |

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

### getRelatedQuestionsSpec

Related questions specification.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.AnswerQueryRequest.RelatedQuestionsSpec|null` |   |

### hasRelatedQuestionsSpec

### clearRelatedQuestionsSpec

### setRelatedQuestionsSpec

Related questions specification.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.AnswerQueryRequest.RelatedQuestionsSpec` |

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

### getGroundingSpec

Optional. Grounding specification.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.AnswerQueryRequest.GroundingSpec|null` |   |

### hasGroundingSpec

### clearGroundingSpec

### setGroundingSpec

Optional. Grounding specification.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.AnswerQueryRequest.GroundingSpec` |

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

### getAnswerGenerationSpec

Answer generation specification.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.AnswerQueryRequest.AnswerGenerationSpec|null` |   |

### hasAnswerGenerationSpec

### clearAnswerGenerationSpec

### setAnswerGenerationSpec

Answer generation specification.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.AnswerQueryRequest.AnswerGenerationSpec` |

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

### getSearchSpec

Search specification.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.AnswerQueryRequest.SearchSpec|null` |   |

### hasSearchSpec

### clearSearchSpec

### setSearchSpec

Search specification.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.AnswerQueryRequest.SearchSpec` |

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

### getQueryUnderstandingSpec

Query understanding specification.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.AnswerQueryRequest.QueryUnderstandingSpec|null` |   |

### hasQueryUnderstandingSpec

### clearQueryUnderstandingSpec

### setQueryUnderstandingSpec

Query understanding specification.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.AnswerQueryRequest.QueryUnderstandingSpec` |

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

### getAsynchronousMode

Deprecated: This field is deprecated. Streaming Answer API will be
supported.

Asynchronous mode control.
If enabled, the response will be returned with answer/session resource
name without final answer. The API users need to do the polling to get
the latest status of answer/session by calling
[ConversationalSearchService.GetAnswer](https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.Client.ConversationalSearchServiceClient#_Google_Cloud_DiscoveryEngine_V1_Client_ConversationalSearchServiceClient__getAnswer__)
or
[ConversationalSearchService.GetSession](https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.Client.ConversationalSearchServiceClient#_Google_Cloud_DiscoveryEngine_V1_Client_ConversationalSearchServiceClient__getSession__)
method.

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

### setAsynchronousMode

Deprecated: This field is deprecated. Streaming Answer API will be
supported.

Asynchronous mode control.
If enabled, the response will be returned with answer/session resource
name without final answer. The API users need to do the polling to get
the latest status of answer/session by calling
[ConversationalSearchService.GetAnswer](https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.Client.ConversationalSearchServiceClient#_Google_Cloud_DiscoveryEngine_V1_Client_ConversationalSearchServiceClient__getAnswer__)
or
[ConversationalSearchService.GetSession](https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.Client.ConversationalSearchServiceClient#_Google_Cloud_DiscoveryEngine_V1_Client_ConversationalSearchServiceClient__getSession__)
method.

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

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

### getUserPseudoId

A unique identifier for tracking visitors. For example, this could be
implemented with an HTTP cookie, which should be able to uniquely identify
a visitor on a single device. This unique identifier should not change if
the visitor logs in or out of the website.

This field should NOT have a fixed value such as `unknown_visitor`.
The field must be a UTF-8 encoded string with a length limit of 128
characters. Otherwise, an `INVALID_ARGUMENT` error is returned.

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

### setUserPseudoId

A unique identifier for tracking visitors. For example, this could be
implemented with an HTTP cookie, which should be able to uniquely identify
a visitor on a single device. This unique identifier should not change if
the visitor logs in or out of the website.

This field should NOT have a fixed value such as `unknown_visitor`.
The field must be a UTF-8 encoded string with a length limit of 128
characters. Otherwise, an `INVALID_ARGUMENT` error is returned.

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

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

### getUserLabels

The user labels applied to a resource must meet the following requirements:

- Each resource can have multiple labels, up to a maximum of 64.

- Each label must be a key-value pair.

- Keys have a minimum length of 1 character and a maximum length of 63 characters and cannot be empty. Values can be empty and have a maximum length of 63 characters.
- Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed.
- The key portion of a label must be unique. However, you can use the same key with multiple resources.
- Keys must start with a lowercase letter or international character. See [Google Cloud
  Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) for more details.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField` |   |

### setUserLabels

The user labels applied to a resource must meet the following requirements:

- Each resource can have multiple labels, up to a maximum of 64.

- Each label must be a key-value pair.

- Keys have a minimum length of 1 character and a maximum length of 63 characters and cannot be empty. Values can be empty and have a maximum length of 63 characters.
- Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed.
- The key portion of a label must be unique. However, you can use the same key with multiple resources.
- Keys must start with a lowercase letter or international character. See [Google Cloud
  Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) for more details.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array|https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField` |

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

### getEndUserSpec

Optional. End user specification.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.AnswerQueryRequest.EndUserSpec|null` |   |

### hasEndUserSpec

### clearEndUserSpec

### setEndUserSpec

Optional. End user specification.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-discoveryengine/latest/V1.AnswerQueryRequest.EndUserSpec` |

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