2.2.0 (latest) 2.0.6 1.34.2 1.33.1 1.32.3 1.31.0 1.30.0 1.29.2 1.28.2 1.26.0 1.25.0 1.24.4 1.23.0 1.22.1 1.21.2 1.19.0 1.18.1 1.17.1 Reference documentation and code samples for the Cloud Datastore V1 Client class Query.

A query for entities.

The query stages are executed in the following order:

1. kind
2. filter
3. projection
4. order + start_cursor + end_cursor
5. offset
6. limit
7. find_nearest

Generated from protobuf message `google.datastore.v1.Query`

## Namespace

Google \\ Cloud \\ Datastore \\ V1

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ projection` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-datastore/latest/V1.Projection>` The projection to return. Defaults to returning all properties. |
| `↳ kind` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-datastore/latest/V1.KindExpression>` The kinds to query (if empty, returns entities of all kinds). Currently at most 1 kind may be specified. |
| `↳ filter` | `https://docs.cloud.google.com/php/docs/reference/cloud-datastore/latest/V1.Filter` The filter to apply. |
| `↳ order` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-datastore/latest/V1.PropertyOrder>` The order to apply to the query results (if empty, order is unspecified). |
| `↳ distinct_on` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-datastore/latest/V1.PropertyReference>` The properties to make distinct. The query results will contain the first result for each distinct combination of values for the given properties (if empty, all results are returned). Requires: \* \* If `order` is specified, the set of distinct on properties must appear before the non-distinct on properties in `order`. |
| `↳ start_cursor` | `string` A starting point for the query results. Query cursors are returned in query result batches and [can only be used to continue the same query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets). |
| `↳ end_cursor` | `string` An ending point for the query results. Query cursors are returned in query result batches and [can only be used to limit the same query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets). |
| `↳ offset` | `int` The number of results to skip. Applies before limit, but after all other constraints. Optional. Must be \>= 0 if specified. |
| `↳ limit` | `Google\Protobuf\Int32Value` The maximum number of results to return. Applies after all other constraints. Optional. Unspecified is interpreted as no limit. Must be \>= 0 if specified. |
| `↳ find_nearest` | `https://docs.cloud.google.com/php/docs/reference/cloud-datastore/latest/V1.FindNearest` Optional. A potential Nearest Neighbors Search. Applies after all other filters and ordering. Finds the closest vector embeddings to the given query vector. |

### getProjection

The projection to return. Defaults to returning all properties.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google\Protobuf\RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-datastore/latest/V1.Projection>` |   |

### setProjection

The projection to return. Defaults to returning all properties.

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

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

### getKind

The kinds to query (if empty, returns entities of all kinds).

Currently at most 1 kind may be specified.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google\Protobuf\RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-datastore/latest/V1.KindExpression>` |   |

### setKind

The kinds to query (if empty, returns entities of all kinds).

Currently at most 1 kind may be specified.

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

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

### getFilter

The filter to apply.

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

### hasFilter

### clearFilter

### setFilter

The filter to apply.

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

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

### getOrder

The order to apply to the query results (if empty, order is unspecified).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google\Protobuf\RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-datastore/latest/V1.PropertyOrder>` |   |

### setOrder

The order to apply to the query results (if empty, order is unspecified).

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

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

### getDistinctOn

The properties to make distinct. The query results will contain the first
result for each distinct combination of values for the given properties
(if empty, all results are returned).

Requires:

- If `order` is specified, the set of distinct on properties must appear before the non-distinct on properties in `order`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google\Protobuf\RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-datastore/latest/V1.PropertyReference>` |   |

### setDistinctOn

The properties to make distinct. The query results will contain the first
result for each distinct combination of values for the given properties
(if empty, all results are returned).

Requires:

- If `order` is specified, the set of distinct on properties must appear before the non-distinct on properties in `order`.

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

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

### getStartCursor

A starting point for the query results. Query cursors are
returned in query result batches and
[can only be used to continue the same
query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets).

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

### setStartCursor

A starting point for the query results. Query cursors are
returned in query result batches and
[can only be used to continue the same
query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets).

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

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

### getEndCursor

An ending point for the query results. Query cursors are
returned in query result batches and
[can only be used to limit the same
query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets).

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

### setEndCursor

An ending point for the query results. Query cursors are
returned in query result batches and
[can only be used to limit the same
query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets).

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

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

### getOffset

The number of results to skip. Applies before limit, but after all other
constraints. Optional. Must be \>= 0 if specified.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### setOffset

The number of results to skip. Applies before limit, but after all other
constraints. Optional. Must be \>= 0 if specified.

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

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

### getLimit

The maximum number of results to return. Applies after all other
constraints. Optional.

Unspecified is interpreted as no limit.
Must be \>= 0 if specified.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google\Protobuf\Int32Value|null` |   |

### hasLimit

### clearLimit

### getLimitUnwrapped

Returns the unboxed value from `getLimit()`

The maximum number of results to return. Applies after all other
constraints. Optional.
Unspecified is interpreted as no limit.
Must be \>= 0 if specified.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int|null` |   |

### setLimit

The maximum number of results to return. Applies after all other
constraints. Optional.

Unspecified is interpreted as no limit.
Must be \>= 0 if specified.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `Google\Protobuf\Int32Value` |

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

### setLimitUnwrapped

Sets the field by wrapping a primitive type in a Google\\Protobuf\\Int32Value object.

The maximum number of results to return. Applies after all other
constraints. Optional.
Unspecified is interpreted as no limit.
Must be \>= 0 if specified.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int|null` |

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

### getFindNearest

Optional. A potential Nearest Neighbors Search.

Applies after all other filters and ordering.
Finds the closest vector embeddings to the given query vector.

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

### hasFindNearest

### clearFindNearest

### setFindNearest

Optional. A potential Nearest Neighbors Search.

Applies after all other filters and ordering.
Finds the closest vector embeddings to the given query vector.

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

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