# Google Cloud Vector Search V1 Client - Class VectorSearch (0.4.0)

0.4.0 (latest) 0.3.0 0.2.0 0.1.0 Reference documentation and code samples for the Google Cloud Vector Search V1 Client class VectorSearch.

Defines a search operation using a query vector.

Generated from protobuf message `google.cloud.vectorsearch.v1.VectorSearch`

## Namespace

Google \\ Cloud \\ VectorSearch \\ V1

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ vector` | `https://docs.cloud.google.com/php/docs/reference/cloud-vectorsearch/latest/V1.DenseVector` A dense vector for the query. |
| `↳ sparse_vector` | `https://docs.cloud.google.com/php/docs/reference/cloud-vectorsearch/latest/V1.SparseVector` A sparse vector for the query. |
| `↳ search_field` | `string` Required. The vector field to search. |
| `↳ filter` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Struct` Optional. A JSON filter expression, e.g. {"genre": {"$eq": "sci-fi"}}, represented as a google.protobuf.Struct. |
| `↳ top_k` | `int` Optional. The number of nearest neighbors to return. |
| `↳ output_fields` | `https://docs.cloud.google.com/php/docs/reference/cloud-vectorsearch/latest/V1.OutputFields` Optional. Mask specifying which fields to return. |
| `↳ search_hint` | `https://docs.cloud.google.com/php/docs/reference/cloud-vectorsearch/latest/V1.SearchHint` Optional. Sets the search hint. If no strategy is specified, the service will use an index if one is available, and fall back to the default KNN search otherwise. |
| `↳ distance_metric` | `int` Optional. The distance metric to use for the KNN search. If not specified, DOT_PRODUCT will be used as the default. |

### getVector

A dense vector for the query.

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

### hasVector

### setVector

A dense vector for the query.

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

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

### getSparseVector

A sparse vector for the query.

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

### hasSparseVector

### setSparseVector

A sparse vector for the query.

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

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

### getSearchField

Required. The vector field to search.

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

### setSearchField

Required. The vector field to search.

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

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

### getFilter

Optional. A JSON filter expression, e.g. {"genre": {"$eq": "sci-fi"}},
represented as a google.protobuf.Struct.

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

### hasFilter

### clearFilter

### setFilter

Optional. A JSON filter expression, e.g. {"genre": {"$eq": "sci-fi"}},
represented as a google.protobuf.Struct.

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

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

### getTopK

Optional. The number of nearest neighbors to return.

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

### hasTopK

### clearTopK

### setTopK

Optional. The number of nearest neighbors to return.

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

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

### getOutputFields

Optional. Mask specifying which fields to return.

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

### hasOutputFields

### clearOutputFields

### setOutputFields

Optional. Mask specifying which fields to return.

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

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

### getSearchHint

Optional. Sets the search hint. If no strategy is specified, the service
will use an index if one is available, and fall back to the default KNN
search otherwise.

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

### hasSearchHint

### clearSearchHint

### setSearchHint

Optional. Sets the search hint. If no strategy is specified, the service
will use an index if one is available, and fall back to the default KNN
search otherwise.

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

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

### getDistanceMetric

Optional. The distance metric to use for the KNN search. If not specified,
DOT_PRODUCT will be used as the default.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | Enum of type [DistanceMetric](https://docs.cloud.google.com/php/docs/reference/cloud-vectorsearch/latest/V1.DistanceMetric). |

### setDistanceMetric

Optional. The distance metric to use for the KNN search. If not specified,
DOT_PRODUCT will be used as the default.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` Enum of type [DistanceMetric](https://docs.cloud.google.com/php/docs/reference/cloud-vectorsearch/latest/V1.DistanceMetric). |

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

### getVectorType

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